[Qt-interest] SQLite and create new database file
Christoph Duelli
duelli at melosgmbh.de
Mon Jan 19 08:09:59 CET 2009
>>> QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
>>> db.setDatabaseName(fileName);
>>> db.open();
note that addDatabase and setDatabaseName both *do not* create tables in the
(or a) database.
QDatabase is a database *connection* (and said calls just establish and name
a connection to a database).
Creating a table in a database is done with SQL (see QSqlQuery):
QSqlQuery q; // pass your QSqlDatabase if more than one connection
q.exec("your sql command");
...
There are other possibilites, too. See the Qt docs.
HTH
Christoph
More information about the Qt-interest-old
mailing list