Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions |
The database handles simultaneous query attempts from multiple applications by blocking new queries while existing queries are running. However, the Qt Extended applications and libraries are designed to only create short-lived/temporary SQL queries.
Qt Extended supports a number of languages and so strings should be stored in a Unicode-compatible encoding such as UTF8 or UTF16. A localized string comparison operation must be provided by the database as localeAwareCompare needs to be equivalent to the QString::localeAwareCompare() function. The SQLite version of this function is as follows:
int sqliteLocaleAwareCompare(void *, int ll, const void *l, int rl, const void *r) { QString left = QString::fromUtf16((const ushort *)l, ll); QString right = QString::fromUtf16((const ushort *)r, rl); return QString::localeAwareCompare(left, right); }
Much of Qtopia / Qt Extended 4 was developed with the SQLite database in mind. So while it is intended that embedded SQL statements are not dependent on any specific implementation it is possible there will be incompatibilities with SQL databases that do not support the SQLite SQL language subset. Any incompatiblities will be addressed in the affected libraries and applications as they are identified. An exception to this is the creation of tables and constraints which is explained in the section Ensuring Table Schemas.
Qt Extended is intended for use on embedded devices and it is important that the database has small implementation and dataset sizes in addition to good performance. Currently SQLite Version 3 is being used with Qt Extended and provides a benchmark for size and performance requirement as follows:
Qt Extended uses the QSql classes provided by Qt and so a Qt SQL database driver is required for access to the database. If the access to the database is not provided by one of the existing Qt SQL database drivers a new SQL database driver will need to be implemented. Additional documentation on SQL database drivers for Qt can be found at Qt SQL Module - Drivers.
Code related to specifying a Qt Extended driver as well as many other driver-specific code can be found in:
$QPEDIR/src/libraries/qtopia/qtopiasql.cpp
however relevant sections may be moved to custom.cpp in future.
Incompatibilities between SQL implementations exist when creating tables and specifying constraints on fields. Qt Extended overcomes this limitation by providing a mechanism to abstract the creation of tables in the database as follows:
$QPEDIR/src/libraries/qtopia/resources/categories.sqlite.sql
<file alias="QtopiaSql/QSQLITE/categories">resources/categories.sqlite.sql</file>
The alias has the form QtopiaSql/<driver>/<table> where:
QtopiaSql::ensureSchema("categories");
QStringList tables; tables << "categories"; tables << "contacts"; tables << "emailaddresses"; tables << "contactcategories"; tables << "contactcustom"; QtopiaSql::ensureSchema(tables);
Some schemas may depend on others and it is the responsibility of the application or library to ensure schemas are loaded in the correct order. Constraints specified in Qt Extended are almost entirely foreign key constraints, although currently there are also system data constraints for the categories table.
Copyright © 2009 Trolltech | Trademarks | Qt Extended 4.4.3 |