Home

Awesome

NLDatabase

Lightweight C++ wrapper for SQLite.

Requirements

Usage

Let's open a database file and read some rows:

#include "NLDatabase.h"


using namespace std;
using namespace NL::DB;


int main(int argc, const char * argv[]) {

    Database db( "test.sqlite" );
    
    auto results = db.query("SELECT * FROM test WHERE name <> ?", "TOM" );
    
    for ( auto & row : results ) {
        cout << "column[0]=" << row.column_string( 0 ) << endl;
    }
}

Installation

It's a single header, just drop into your project, link sqlite3 and that's it.

Demo

To run the simple demo, use the Xcode project or build it on the command line like this:

sqlite3 test.sqlite < test.sql
clang -o test -std=c++11 -lsqlite3 -lstdc++ main.cpp
./test

Known problems

See also

Goes well with NLTemplate and possibly Mongoose.