All pastes #583687 Raw Edit

Stuff

public text v1 · immutable
·published 2007-06-22 14:01 UTC
rendered paste body
#include <sqlite3.h>
#include <iostream>
#include <libsqlitewrapped.h>

using std::string;
using std::cout;
using std::endl;

int main()
{
        Database db("tutorial.db");
        if (!db.Connected())
        {
                printf("Database not connected - exiting\n");
                exit(-1);
        }
        Query q(db);
        q.execute("CREATE TABLE ips ( start INTEGER(10) PRIMARY KEY, end INTEGER(10), country VARCHAR(10))");
        q.execute("INSERT INTO ips(start,end,country) VALUES (0,5000,'NO')");
        q.get_result("SELECT * FROM ips");
        while (q.fetch_row())
        {
                long start = q.getval();
                long end = q.getval();
                string country = q.getstr();
                cout << country << endl;
        }
}