1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#include <stdio.h>
#include <stdlib.h>
# include <sqlite3.h>
static int callback(void *NotUsed, int argc, char **argv, char **azColName){
int i;
for(i=0; i<argc; i++){
printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
}
printf("\n");
return 0;
}
int main()
{
sqlite3 *db;
int rc;
char * errMsg;
rc=sqlite3_open("test1.db",&db);
printf("Hello world! adel\n");
if (rc)
{ printf("connexion null \n");
}
else
{
printf("connexion réussi \n");
sqlite3_close(db);
}
sqlite3_exec(db,"CREATE TABLE table1 (id INTEGER, nom varchar(30), prenom varchar(30))" ,NULL, NULL, &errMsg);
//printf(%c,
//CREATE TABLE table1 (id INTEGER, nom varchar(30), prenom varchar(30);
//sqlite> INSERT INTO table1 values(42, "trax", "traxou");
//fprintf(stderr, "SQL error: %s\n",errMsg );
sqlite3_exec(db,"INSERT INTO table1 values(42, 'trax', traxou')",NULL, NULL, &errMsg);
//printf(%d,&errMsg);
sqlite3_exec(db,"select * from table1",callback, 0, &errMsg);
} |
Partager