views:

57

answers:

1

Hello, I was wondering what the "best" way to verify the structure of my database is with SQLite in Qt / C++. I'm using SQLite so there is a file which contains my database, and I want to make sure that, when launching the program, the database is structured the way it should be- i.e., it has X tables each with their own Y columns, appropriately named, etc. Could someone point my in the right direction? Thanks so much!

+2  A: 

You can get a list of all the tables in the database with this query:

select tbl_name from sqlite_master;

And then for each table returned, run this query to get column information

pragma table_info(my_table);

For the pragma, each row of the result set will contain: a column index, the column name, the column's type affinity, whether the column may be NULL, and the column's default value.

(I'm assuming here that you know how to run SQL queries against your database in the SQLite C interface.)

pkh
Absolutely, thanks for setting me on the right track!
Airjoe