Small. Fast. Reliable.
Choose any three.
*** 1,38 ****
  *: Make sure you have the latest version of SQLite
  *: Make sure you have the latest version of Mingw
  *: Using your favourite text editor, create a file called test.c and save it somwhere you can compile it. Make sure the sqlite.dll file is in the same directory. Here is the code for test.c:
  
!   #include <stdio.h>
!   #include <sqlite.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(int argc, char **argv){
!   sqlite *db;
    char *zErrMsg = 0;
    int rc;
    if( argc!=3 ){
      fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT\n", argv[0]);
      exit(1);
    }
!   db = sqlite_open(argv[1], 0, &zErrMsg);
!   if( db==0 ){
      fprintf(stderr, "Can't open database: %s\n", zErrMsg);
      exit(1);
    }
!   rc = sqlite_exec(db, argv[2], callback, 0, &zErrMsg);
    if( rc!=SQLITE_OK ){
      fprintf(stderr, "SQL error: %s\n", zErrMsg);
    }
!   sqlite_close(db);
    return 0;
!   }
! 
  *: Compile test.c with the following: gcc -o main.exe -I /include sqlite.dll sltest2.c
  *: In the same directory as the compiled c file, enter: "sqlite test.db". This will create a new database named "test.db". Of course, sqlite.exe must either be in this directory or in your path.
  *: Enter the following:
--- 1,44 ----
  *: Make sure you have the latest version of SQLite
  *: Make sure you have the latest version of Mingw
  *: Using your favourite text editor, create a file called test.c and save it somwhere you can compile it. Make sure the sqlite.dll file is in the same directory. Here is the code for test.c:
+ <html>
+ <pre>
+ #include <stdio.h>
+ #include <sqlite.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(int argc, char **argv){
!   sqlite3 *db;
    char *zErrMsg = 0;
+   int res;
    int rc;
    if( argc!=3 ){
      fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT\n", argv[0]);
      exit(1);
    }
!   res = sqlite3_open(argv[1], &db);
!   if( res!=SQLITE_OK ){
!     const char *zErrMsg = sqlite3_errmsg(db);
      fprintf(stderr, "Can't open database: %s\n", zErrMsg);
      exit(1);
    }
!   rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);
    if( rc!=SQLITE_OK ){
      fprintf(stderr, "SQL error: %s\n", zErrMsg);
    }
!   sqlite3_close(db);
    return 0;
! }
! </pre>
! </html>
  *: Compile test.c with the following: gcc -o main.exe -I /include sqlite.dll sltest2.c
  *: In the same directory as the compiled c file, enter: "sqlite test.db". This will create a new database named "test.db". Of course, sqlite.exe must either be in this directory or in your path.
  *: Enter the following: