#include <soci.h>
#include <sqlite3/soci-sqlite3.h>

#include <cassert>
#include <iostream>

using namespace soci;

int main(){
    try {
        session sql(sqlite3, "test.db");
        
        sql << "create table if not exists test_table (val integer)";

        std::size_t v1 = 1000;
        sql << "insert into test_table values (:val)", use(v1);

        row r;
        sql << "select val from test_table", into(r);
        std::size_t v2 = 0;
        r >> v2; // throws bad_cast
        assert(v2 == v1);
    }
    catch (std::exception const &e)
    {
        std::cerr << "Error: " << e.what() << '\n';
    }
}
