Describes how to connect to SQLite database files.
The AnyDAC native driver supports SQLite database version 3.0 and higher.
Read "Using SQLite with AnyDAC" chapter for detailed discussion of SQLite usage in AnyDAC for Delphi application.
AnyDAC supports two SQLite library linking modes:
You can download:
there, Chapter "Precompiled Binaries For Windows", item "This is a DLL" and put it into a folder listed in your PATH environment variable (for example, <System32> folder) or into your application EXE folder. AnyDAC Installer installs SQLITE3.DLL v 3.7.15 into your windows\system32 folder.
there as "sqlite-netFx40-binary-x64-xxxxx.zip". Extract to a folder, copy SQLite.Interop.DLL into SQLITE3.DLL, then put it as above. AnyDAC Installer installs x64 SQLITE3.DLL v 3.7.15 into your windows\system32 folder.To choose linking mode, in AnyDAC\Source\uAD.inc:
When the SQLite client library has not been properly installed, you will get an exception when you try to connect:
[AnyDAC][Phys][SQLite]-314. Cannot load vendor library [SQLITE3.DLL]. The specified module could not be found. Check [SQLITE3.DLL], which is located in one of the PATH directories or in the application EXE directory.
AnyDAC on Linux supports only dynamic linking and requires:
To install on Linux use the commands:
sudo apt-get update sudo apt-get install sqlite3 libsqlite3-dev
AnyDAC on Mac OS X supports only dynamic linking and requires:
It comes preinstalled on Mac OS X. Note, the default Mac OS X libsqlite3.dylib is compiled with limited column metadata capabilities. As result, AnyDAC may fail to detect column auto-incremental mode and optionality.
To link the driver:
To connect to a SQLite database, most applications will need to specify DriverID and Database.
DriverID=SQLite
|
Parameter |
Description |
Example value |
|
Database |
A path to a database. The path value may include environment variables: $(<variable>). Use ':memory:' or empty string to create and connect to empty in-memory database. |
|
|
OpenMode |
A mode to open a database:
|
ReadOnly |
|
Encrypt |
Specified a default encryption mode for a database. The mode may be overridden by an optional password prefix. If it is not specified, then will be used mode, specified by this parameter. Otherwise will be used aes-256. Please, read this for more details. |
|
|
Password |
Specifies a password for an encrypted database. The value may have a form: [ aes-128 | aes-192 | aes-256 | aes-ctr-128 | aes-ctr-192 | aes-ctr-256 | aes-ecb-128 | aes-ecb-192 | aes-ecb-256 :] <password> There optional prefix controls the cipher algorithm to be used. The default value is empty string, which means unencrypted mode. |
|
|
NewPassword |
Specifies a new password for a database and performs an encryption operation:
|
|
|
BusyTimeout |
Sets a "ms" milliseconds to sleep when a table is locked and UpdateOptions.LockWait is set to True. Zero means do not wait. The default value is 10000. |
5000 |
|
CacheSize |
Changes the maximum number of database disk pages that SQLite will hold in memory at once. Each page uses about 1.5K of memory. The default value is 10000. |
10000 |
|
SharedCache |
Enables or disables the SQLite shared cache feature. Please, read this for more details. The default value is True. |
False |
|
LockingMode |
Sets the database connection locking-mode. The value is one of:
|
Exclusive |
|
Synchronous |
Sets the database connection synchronization mode of in-memory cache with database files. The value is one of:
|
Off |
|
ForeignKeys |
Enables foreign key usage for the database connection, when the application is using SQLite v 3.6.19 or higher. The value is one of:
|
Off |
|
StringFormat |
Defines how to represent String values:
|
Unicode |
|
GUIDFormat |
Defines how to store GUID values:
|
Binary |
|
DateTimeFormat |
Defines how to store date and time values:
|
Binary |
|
Extentions |
Enables, disables or specifies the SQLite engine extensions to load:
|
MyExt.dll;FullTS.dll |
|
SQLiteAdvanced |
Additional SQLite database connection options. See the Pragma statements supported by SQLite for details. |
auto_vacuum = 1;page_size = 4096;temp_store = FILE |
|
MetaDefCatalog |
Default database name. Design time code will exclude the catalog name from the object name, if it is equal to MetaDefCatalog. Setting MetaDefCatalog does not change the current database in the SQLite session. The default value is 'MAIN'. |
MyDB |
DriverID=SQLite Database=$(ADHOME)\DB\Data\ADDemo.sdb
DriverID=SQLite Database=\\srv\mydb.sqlite LockingMode=Normal Synchronous=Normal
DriverID=SQLite Database=$(ADHOME)\DB\Data\ADDemo.sdb NewPassword=aes-256:123qwe
DriverID=SQLite Database=c:\temp\test.db Password=123qwe
DriverID=SQLite Database=:memory:
|
What do you think about this topic? Send feedback!
|