PDA

View Full Version : show all databases using "QSQLITE"



junior-root
10th September 2017, 02:38
Hi,
I managed to create some databases, to create tables and put some data using "QSQLITE" driver. I can read and write data without problems.

What I want is to be able to get all databases names created with "QSQLITE". Can this be possible?
I try to get all databases names without succes.
Can someone provide me a simple Qt code that can do that?
Thank you.

d_stranz
10th September 2017, 22:37
What I want is to be able to get all databases names created with "QSQLITE".

QSQLITE is just a wrapper around the SQLite library. SQLite databases are usually just ordinary disk files. There is no server such as is used with MySQL or PostgreSQL. So since there is no server, there is nothing to connect to to ask what databases are being managed. Not only that, but you can name an SQLite database file with any name and extension you want.

There is no practical way to ask which files are SQLite databases except to go through the entire filesystem and try to open every file with the SQLite driver.

stoyanps
12th September 2017, 13:54
What I want is to be able to get all databases names created with "QSQLITE". Can this be possible?

You can keep track of SQLite databases created from your application inside the application - for example as a list of file names written in file. But this is not very reliable method since a database file can be moved outside your application and this make the path in your list invalid.