lundi 29 juin 2015

SQLite - Database file stops growing

I'm using SRombauts SQLite Wrapper for C++ together with SQLite version 3.8.10.2 on a Debian Jessie machine.
I can INSERT or SELECT data without problems, but the strange thing is, that the database always stops growing at 56852480 bytes (I've got this information from the ls -l database.db command).

What I'm trying to accomplish is to insert the data of a big (around 280'000 lines) csv file into the database.

Well, this is a simplified version of my code:

#include <iostream>
#include <csv.h> //small csv class of mine
#include <SQLiteCpp/SQLiteCpp.h>
#include <string>

int main()
{
    SQLite::Database db("database.db", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE);
    db.exec("DROP TABLE IF EXISTS bernd");

    //simplified version of the table, there would be more columns
    db.exec("CREATE TABLE bernd(id INTEGER PRIMARY KEY, loads_of_data TEXT)");
    SQLite::Transaction tr;
    SQLite::Statement stmt("INSERT INTO bernd(loads_of_data) values(?)");

    Csv csv("file.csv");
    while(csv.getNext())
    {
        stmt.bind(1, csv.getValue("loads_of_data"));
        stmt.executeStep();
        stmt.reset();
    }
    tr.commit();
}

I know I should use some try{} catch{} blocks, but I wanted to keep the code small.

I read some things about SQLite limits but setting the only one slightly significant for this case, SQLITE_MAX_PAGE_COUNT, to it's maximum value made no difference.

What's going on here? It seems no one else encountered this problem and I'm really confused!
Any insight or hint into the right direction is highly appreciated!

Aucun commentaire:

Enregistrer un commentaire