Small. Fast. Reliable.
Choose any three.

This information is obsolete. You are looking at the CVSTrac source management system display for SQLite that was replaced by Fossil on 2009-08-11. The information shown here has not been updated since that cut-over. These pages are retained for historical reference only.

  • 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");
      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]);
      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);
      rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);
      if( rc!=SQLITE_OK ){
        fprintf(stderr, "SQL error: %s\n", zErrMsg);
      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:

  sqlite> CREATE TABLE Orders
   ...> (
   ...> Orders
   ...> );

  • And the following:

  sqlite> INSERT INTO orders VALUES ("Order1");
  sqlite> INSERT INTO orders VALUES ("Order2");

  • And then:


  • Type the following command: main test.db "SELECT * FROM Orders;". If you are using a different db, modify the SQL statement accordingly.
  • You should see:

  C:\EJD\MinGW\bin>main test.db "SELECT * FROM Orders;".
  Orders = Order1
  Orders = Order2