This annoyed me since I saw .DatabaseName in the documentation:
How is this working ?
Is it computed from the passed FolderItem Name ?
and so on.
The worst is that each time I search about it, I failed to reach it under SQLitedatabase.
Of course, I do not searched on the correct location.
In fact, this property is Read/Write. In a current projec, I added a name just after creating the Database file, so I can access to it from everywhere db is valid…
Unfortunately, the name is not saved to disk; but this is not a real trouble; a solution exists:
a. you have a Service TABLE:
Table with one Record that holds some specific values for this db: add another specs here.
b. An Information TABLE ?
You can use the file name after removed its extension… Good to know from where the file comes…
DatabaseName is mostly used in database servers like MySQL and Postgres.
SQlitedatabase.DatabaseName is not mentioned on the documentation. It is showing as autocomplete on the IDE. Maybe a bug (IDE or Documentation).
As we are not connecting to a server that can have multiple databases with SQLite and instead we are connecting directly to the database, then DatabaseName is not needed for SQLite.
I don’t know if you have a question or just posting an idea.
It is the DB name for servers. Not tied to files, just the name the server knows the DB there.
I guess you are saying that you couldn’t find the equivalent for SQLiteDatabase.
That’s because SQLite uses a file approach with some other standards to handle DB schemas. If you open one DB file only, is assumes the alias “main” for your DB. As it is the only DB open you can just omit the “main.” part of the schema reference so “SELECT * FROM mytab” is the same thing as “SELECT * FROM main.mytab”. “main” is the assumed “database name”.
But if you attach another DB file, you can set a new alias for it as
db.AddDatabase(theFolderItemPointingtoMySQliteFile, "extras")
// "extras" is the database name alias containing its own sets of structures and tables
And you can mix both as something like this:
SELECT u.id, u.name, ec.credits FROM main.users u JOIN extras.credit ec ON u.id = ec.user_id