Hi! we've using SQLite on our software since about a month ago, and still i have some questions about how does sqlite works at all.

I have the following sourcecode to check if a database is already created, if yes then just open, if not, open it and create the appropiate schema for the database:

if ( sqlite3_open_v2(path,&historydb,SQLITE_OPEN_READWRITE,NULL) != SQLITE_OK) {

       // Create the database

       sqlite3_close(historydb);

       if (sqlite3_open(path,&historydb) == SQLITE_OK) {

           // Now we create the default tables

           strcpy(query,"create table parameters (param_id integer primary key, 
param_name text(100));create table data_values (timestamp integer(4), value real, 
param_id integer(2));");

           rc = sqlite3_exec(historydb,query,process_query,NULL,&errmsg);

           if (rc == SQLITE_OK) {

               strcpy(query,"pragma default_cache_size=40;");

               rc=sqlite3_exec(historydb,query,process_query,NULL,&errmsg);

           }

           if (rc != SQLITE_OK) {

               // An error ocurred during database creation

              printf("SQL Error: ",errmsg);

               sqlite3_free(errmsg);

               return 0;

           }

       } else {

           // Unable to create database

              return 0;

       }

   }


This works fine under linux, and in windows if i run it onto gdb, but not if i call my object code from the command prompt, my question is if there's a better solution for check if the database is already created, something like a "describe" SQL Command (in oracle) that help to know if the schema is already there on the database?

Thank you!

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to