Skip to content

Instantly share code, notes, and snippets.

@TheAnonymous
Created November 2, 2010 13:13
Show Gist options
  • Save TheAnonymous/659582 to your computer and use it in GitHub Desktop.
Save TheAnonymous/659582 to your computer and use it in GitHub Desktop.
How to read a SQLite Database
#include <sqlite3.h>
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
int zeile;
int spalte;
const char * datenbankname = "test.db";
char **results = NULL;
string results2;
char *errmsg = NULL;
sqlite3 *db;
if(sqlite3_open(datenbankname, &db) != SQLITE_OK)
cout << "Error: could not open database: " << datenbankname << endl;
cout << "sdgsg" << endl;
sqlite3_get_table(db, "select * from testtable", &results, &zeile, &spalte, &errmsg);
cout << results[6]<< " " << results[7] <<endl ;
sqlite3_close(db);
return 0;
}
sqlite3 test.db
> create table testtable(spalte 1,spalte2);
> insert into testtable values(value1,value2,value3,...);
contrl+D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment