File Extensions for Data Base…

…or How do I get the data base kind from the file (name, something else) ?

In other words, I want to display information about data base and I am stopped at how do I recognize what DB engine is the owner of this file ?

I can deduce that information from the SQLite file extension (if set to .sqlite, otherwise I do not know).

I am out of ideas. I searched here, there and everywhere in the internet and I do not found the beginning of an idea.

And You ?

never rely on the name or extension… they no longer have the same strict meanings as in days past.

an SQLite database for example can have any (or no) extension.

Either open the file as a binary stream and look for key values, or just attempt to “use” the file and catch any exceptions

On Mac you can use the file command. More info at https://ss64.com/osx/file.html.

Lack of rules, I was fearing that…

Thanks for the answers.

For SQLite, there is a magic key (actual value: SQLite format 3\\000), but in other dbs ?

BTW: is it possible (like with SQLite) to create local DB files with PostGreSQL and other Xojo built-in Data Bases ? (if so, I can explore closely their files) ?

FYI… an encrypted SQLIte database has no "magic key " or orther method of ID… and the FILE command reports it as “DATA”

@Emile Schwarz — Well only SQLite databases have a single file for the whole database. Other databases can be spread over several locations (foldersà and you should not attempt to access them!

Doh !

This is why we need rules, I suppose.

Thank you guys…

oh I’m sure there are others besides sqlite
firebird and Filemaker can both be single file
Not sure they are always single file though

Here’s what I implemented (displays SQLite db files / Icon) / have in mind:

display the kind of Data Base,
display the icon for that Data Base (red feather for SQLite),

The Listbox is populated at Open time from a dedicated Folder, the PopupMenu displays the number of Records (19) and the TABLE name.

That window is a work in progress.

[quote=453241:@Emile Schwarz]…or How do I get the data base kind from the file (name, something else) ?

I can deduce that information from the SQLite file extension (if set to .sqlite, otherwise I do not know).
[/quote]
None of my sqlite databases has any extension at all.

There are even people who change the file extentions claiming they change the kind of file (from avi to moov; do not laugh, I heard it !).

That said, I created “my file extension” for sqlite db data file 6,5 years ago (bad idea).

My Lenovo (bouhhhhh) laptop never display any file extension in 4 years (then gone to repair and comes back (from factory plant) with broken Touch Screen: I will never brought anything from them anymore !