How do I execute an .schema command using Qt's SQLITE driver?
Greetings everybody.
I'm developing a database application using SQLITE. I would like to check at start up if my database has been correctly initialized and its structure is O.K. So I wonder first, if it's possible to compare the SqLite .schema command's output with my start up SQL script, and second, how could I do that using Qt's SqLite driver?
Re: How do I execute an .schema command using Qt's SQLITE driver?
The ".schema" command is a part of the Sqlite command line client, and not part of Sqlite SQL. You can access schema information with standard SQL queries against the sqlite_master table. See http://www.sqlite.org/faq.html#q7
Re: How do I execute an .schema command using Qt's SQLITE driver?
Re: How do I execute an .schema command using Qt's SQLITE driver?
You could also look at QSqlDatabase::tables() for a list of table names and QSqlDatabase::record() for column names.
Re: How do I execute an .schema command using Qt's SQLITE driver?
Quote:
You could also look at QSqlDatabase::tables() for a list of table names and QSqlDatabase::record() for column names.
Yes, but that will not provide me the exact SQL CREATE statement used to create the structure of each table. Querying sqlite_master, instead, will do it.