Skip to content

Instantly share code, notes, and snippets.

@keks
Created August 13, 2011 23:38
Show Gist options
  • Save keks/1144370 to your computer and use it in GitHub Desktop.
Save keks/1144370 to your computer and use it in GitHub Desktop.
sqlite_read
#include "stdlib.h"
#include "stdio.h"
#include "sqlite/sqlite3.h"
int gotmail(void* NotUsed, int colcount, char** qresult, char** colname);
sqlite3* db;
char * EMSG = NULL;
int main(){
const char* sql_data = "SELECT value from config WHERE key='email'";
int rc = sqlite3_open_v2("config.db", &db, SQLITE_OPEN_READONLY, NULL);
if( rc )
exit(-1);
rc = sqlite3_exec(db, sql_data, &gotmail, NULL, &EMSG);
if( rc ){
fprintf(stderr, "%s\n", EMSG);
exit(-2);
}
return(0);
}
int gotmail(void* NotUsed, int colcount, char** qresult, char** colname){
printf("%s\n",*qresult);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment