|

C++ wrapper library for SQLite
SQLite++ is a cross-platform C++ wrapper
library for SQLite. It is designed to make using the SQLite C library
easy without sacrificing performance. SQLite++ also supports
BLOBS, TwoFish encryption and ZLib compression*.
SQLite++ consists of 4 main classes and a few utility methods for
encoding/decoding, encrypting/decrypting and compressing/decompressing
data. These classes make it super-easy to begin using SQLite
immediately without having to write lots of infrastructure code as you
would otherwise need to do. The main classes are:
- SqliteDb
- Dataset
- Columns (Collection)
- Column
Open and query a database with just a few lines of code. Save
yourself weeks of coding and debugging with this robust and easy to use
class library. SQLite++ uses standard C++ (no platform-specific code), and the Standard
Template Library (STL).
* Note that you must
obtain the ZLib library for your platform separately if
you want
to use the compression methods. SQLite++ is only tested
with the Windows
version (available from
www.gzip.org).
Consider how easy it is to open a database and view the column names, types
and values of an entire table:
SqliteDb DB;
Dataset* pDS;
std::string sErr;
if( DB.open( "Northwind.db", 0, &sErr ) )
{
if( DB.exec( "SELECT * FROM Categories", &pDS, &sErr ) == SQLITE_OK )
{
Column* pCol;
Columns* pCols;
pCols = pDS->getColumns();
// move through the dataset
while( !pDS->eof() )
{
pCol = pCols->first();
while( pCol )
{
std::cout << "Name: " << pCol->name()
<< "\n";
std::cout << "Type: " << pCol->type()
<< "\n";
std::cout << "Value: " << pCol->value()
<< "\n\n";
pCol = pCols->next();
}
pDS->moveNext();
}
}
else
std::cout << sErr;
}
else
std::cout << sErr;
|
Access Columns by name or ordinal
index:
// get column by ordinal index
pCol = pCols->getColumn(1);
// get column by name (case insensitive)
pCol = pCols->getColumn("CategoryName");
|
Move through a dataset forwards or backwards
pDS->moveLast();
while( !pDS->bof() )
{
pCol = pCols->first();
while( pCol )
{
std::cout << "Name: " << pCol->name()
<< "\n";
std::cout << "Type: " << pCol->type()
<< "\n";
std::cout << "Value: " << pCol->value()
<< "\n\n";
pCol = pCols->next();
}
pDS->moveBack();
}
|
Move to any record number or get the number of rows
pDS->moveTo();
int nRows = pDS->numRows();
|
Efficient algorithm makes loading a row lightning fast.
ENCRYPTION and CompressionSQLite++
has added functions for compressing/decompressing and
encrypting/decrypting, making it very easy to perform these
functions on-the-fly. The encryption type is TwoFish, and
the compression type is ZLib.
How to use ENCRYPT and DECRYPT
To use direct
encryption/decryption, you must first set the Cipher Key using
the SqliteDb.setCipherKey property. Here is how to use the new
ENCRYPT and DECRYPT keywords:
UPDATE Customers SET LastName
= ENCRYPT('Smith')
WHERE CustomerId = 1
SELECT DECRYPT(LastName)
FROM Customers WHERE UPPER(DECRYPT(LastName)) = 'SMITH'
UPDATE Customers SET Notes =
COMPRESS('The
customer was satisfied with the results blah blah blah')
WHERE CustomerId = 1
SELECT DECOMPRESS(Notes)
FROM Employees WHERE UPPER(DECRYPT(LastName)) = 'SMITH'
|
|