RAD Studio XE3 introduces a new dbExpress driver which enables connectivity to SQLite 3.x in Win32, Win64, and OSX applications. The driver is written in Delphi and the source code is provided. In this blog post, I’ll list a few things you need to do to get set up to use this driver and also explain the purpose of a couple of the connection properties.
First off on Windows, you will need to download the SQLite client from http://www.sqlite.org/download.html and verify that sqlite3.dll can be found by your application. Once you have done this you can easily build FireMonkey and VCL applications that connect to SQLite using dbExpress. Drop a TSQLConnection onto your form, set the Driver property to Sqlite and away you go. If you choose to create a console application instead, make sure that you use the Data.DbxSqlite unit so that the driver is registered in the driver registry. If you are creating an application for OSX, ensure that libsqlite3.dylib is present on the machine you are deploying to.
The SQLite driver supports a connection property called ColumnMetaDataSupported which can be set to True or False. This property is in place because sqlite3.dll (or libsqlite3.dylib) can be compiled with or without the SQLITE_ENABLE_COLUMN_METADATA C-preprocessor symbol being defined. This symbol determines whether certain metadata APIs are available. On Windows, the symbol is defined in the dll they provide for you so we have set the default value of ColumnMetaDataSupported to True. On OSX, this symbol is not defined so we default to False. However, as SQLite provides source, you could choose to compile the SQLite client library yourself either way.
FailIfMissing is another property that the SQLite driver supports. If this is set to False and the database you specify is not found, a new database will be created for you. When this property is set to True, an exception will be raised when the database is not found instead.
That’s all I’ll cover in this blog post. Connecting to SQLite should be pretty straightforward.Posted by sablas on October 2nd, 2012 under SQLite, XE3, dbExpress |