Created
August 13, 2011 23:38
-
-
Save keks/1144370 to your computer and use it in GitHub Desktop.
sqlite_read
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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