The SOCI SQLite3 backend is supported for use with SQLite3 >= 3.1
|SQLite3 version||Operating System||Compiler|
|3.5.2||Mac OS X 10.5||g++ 4.0.1|
|3.1.3||Mac OS X 10.4||g++ 4.0.1|
|3.2.1||Linux i686 2.6.10-gentoo-r6||g++ 3.4.5|
|3.3.4||Ubuntu 5.1||g++ 4.0.2|
|3.3.4||Windows XP||(cygwin) g++ 3.3.4|
|3.3.4||Windows XP||Visual C++ 2005 Express Edition|
|3.3.8||Windows XP||Visual C++ 2005 Professional|
|3.4.0||Windows XP||(cygwin) g++ 3.4.4|
|3.4.0||Windows XP||Visual C++ 2005 Express Edition|
The SOCI SQLite3 backend requires SQLite3's
libsqlite3 client library.
To establish a connection to the SQLite3 database, create a Session object
SQLite3 backend factory together with the database file name:
session sql(sqlite3, "database_filename");
The only option for the connection string is the name of the file to use as a database.
Once you have created a
Session object as shown above, you can use it to access the database, for example:
int count; sql << "select count(*) from invoices", into(count);
The SQLite3 backend supports the use of the SOCI
Row class, which facilitates retrieval of data whose type is not known at compile time.
Row::get<T>(), the type you should pass as T depends upon the underlying database type.
For the SQLite3 backend, this type mapping is complicated by the fact the SQLite3 does not enforce types *, and makes no attempt to validate the type names used in table creation or alteration statements. SQLite3 will return the type as a string, SOCI will recognize the following strings and match them the corresponding SOCI types:
|SQLite3 Data Type||SOCI Data Type||
* There is one case where SQLite3 enforces type. If a column is declared as "integer primary key", then SQLite3 uses that as an alias to the internal ROWID column that exists for every table. Only integers are allowed in this column.
(See the dynamic resultset binding documentation for general information on using the
int id = 7; sql << "select name from person where id = :id", use(id, "id")
The backend also supports the SQLite3 native numbered syntax, "one or more literals can be replace by a parameter "?" or ":AAA" or "@AAA" or "$VVV" where AAA is an alphanumeric identifier and VVV is a variable name according to the syntax rules of the TCL programming language." :
int i = 7; int j = 8; sql << "insert into t(x, y) values(?, ?)", use(i), use(j);
The SQLite3 backend has full support for SOCI's bulk operations interface. However, this support is emulated and is not native.
Transactions are also fully supported by the SQLite3 backend.
The SQLite3 backend supports working with data stored in columns of type Blob, via SOCI's blob class. Because of SQLite3 general typelessness the column does not have to be declared any particular type.
In SQLite3 RowID is an integer. "Each entry in an SQLite table has a unique integer key called the "rowid". The rowid is always available as an undeclared column named ROWID, OID, or _ROWID_. If the table has a column of type INTEGER PRIMARY KEY then that column is another an alias for the rowid."
Nested statements are not supported by SQLite3 backend.
Stored procedures are not supported by SQLite3 backend
SOCI provides access to underlying datbabase APIs via several getBackEnd() functions, as described in the beyond SOCI documentation.
The SQLite3 backend provides the following concrete classes for navite API access:
|Accessor Function||Concrete Class|
Copyright © 2004-2009 Maciej Sobczak, Stephen Hutton, David Courtney