Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt and Sqlite examples

Tags:

I am looking for some example code using Qt and it's SQL module with Sqlite driver. Main reason I need examples for is that I've prior experience with Qt's database interface and Sqlite has some weird behavior with field types (types are stored per-field, not per-column).

like image 467
Saulius Žemaitaitis Avatar asked Sep 15 '09 21:09

Saulius Žemaitaitis


People also ask

What is SQLite in Qt?

SQLite is a small C library that implements a self-contained, embeddable, zero-configuration SQL database engine. Used in Qt SQL Lite plugin.

How do you create a database in Qt?

db" QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db. setDatabaseName(path); db. open(); QSqlQuery query; // And he should insert some data, as the answer above mentioned query. exec("create table person " "(id integer primary key, " "firstname varchar(20), " "lastname varchar(30), " "age integer)");


1 Answers

The Qt 5 SQL examples use SQLite as this does not require a database server. You should be able to go from the supplied examples to your own sample code pretty quickly.

like image 103
Dirk Eddelbuettel Avatar answered Sep 18 '22 11:09

Dirk Eddelbuettel