dbcreate.c (703B)
1 /** 2 * Create an SQLite database, which uses serialized mode 3 * to prevent horrible file corruption issues. 4 */ 5 6 #include <err.h> 7 #include <sqlite3.h> 8 #include <stdio.h> 9 #include <stdlib.h> 10 11 static void 12 usage(char *c) 13 { 14 printf("Usage: %s <db>\n" 15 " where\n" 16 "<db> path to database to create\n"); 17 exit(1); 18 } 19 20 int 21 main(int argc, char *argv[]) 22 { 23 sqlite3 *db; 24 int rc; 25 26 if (argc != 2) { 27 usage(argv[0]); 28 } 29 30 rc = sqlite3_open(argv[1], &db); 31 32 if (rc) { 33 errx(EXIT_FAILURE, "database opening error: %s\n", 34 sqlite3_errmsg(db)); 35 } else { 36 fprintf(stderr, "Opened database successfully\n"); 37 } 38 39 while (sqlite3_close(db) != SQLITE_OK) { 40 } 41 42 return 0; 43 }