mercredi 14 octobre 2015

Get data from sqlite3 in C

I am creating a server that saves msgs into a database( sqlite3 )then send them to some clients, The question is how to get data from the database, by the way I am new into the sqlite3 API in C,here is some part of the code I Have:

snprintf( commands, 256, "SELECT Msg FROM %s WHERE timeStamp BETWEEN %ld AND %ld;",
        sn, ( serverTime - diff->tv_sec ), serverTime );

rc = sqlite3_prepare_v2( db, commands, -1, &res, 0 );

while( sqlite3_step( res ) == SQLITE_ROW )
{

    // ????????

}

I have a table with usernames that has 3 columns: "Id INTEGER PRIMARY KEY, timeStamp INT, Msg TEXT"

I want to get the msgs that are the difference of server time and last connection from the client ( serverTime - diff->tv_sec )

Aucun commentaire:

Enregistrer un commentaire