Allowable characters in sqlite3 database file names
Posted
#1
(In Topic #937)
Regular

My program has an edit field to enter a database name, which in my rough draft I don't edit check, then the program either creates or loads the file depending upon whether the file exists.
Code (gambas)
- '=============================================================================
- With theDB
- .Type = "sqlite3"
- .Host = ArgDirName
- .Name = ""
- .Databases.Add(ArgFileName)
- '=============================================================================
- With MyDB
- .Type = "sqlite3"
- .Host = ArgDirName
- .Name = ArgFileName
- '=============================================================================
Before I code a workaround, e.g. create a plain named file and rename it, I'd like to know if there is something going on that I am not aware of. I haven't done that much DB programming in Gambas.
Thanks,
Ced
.... and carry a big stick!
Posted
Expert

What are the special characters that are giving you the issue ?
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Enthusiast

but found this:
Naming Conventions for SQLite
Each database, table, column, index, trigger, or view has a name by which it is identified
and almost always the name is supplied by the developer.The rules governing how a
valid identifier is formed in SQLite are set out in the next few sections.
Valid Characters
An identifier name must begin with a letter or the underscore character, which may be
followed by a number of alphanumeric characters or underscores. No other characters
may be present.
Posted
Regular

But just as a "schoolroom" example, consider naming some file "a b c d goldfish". This would be a legal filename and would appear in a file manager fine, BUT just consider running
Code
less a b c goldfishWell, SQLite is generally not even as clever as bash.
b
Posted
Regular

This is apparently a Gambas' specific problem. The OS (Ubuntu on Raspberry Pi) has no problem, nor does the sqlite application. The quirk is that I can open a database with these characters, but I can't create one the regular way.
The name pattern that blew up first was: something{secret}goes~here
I am using the name as a four element data row in higher level databases, but prefer symbolically meaningful delimiters. I could also use three underscores instead.
I was thinking maybe my code wasn't proper. Should I report this as a bug?
.... and carry a big stick!
1 guest and 0 members have just viewed this.


