Changeset 15637

Show
Ignore:
Timestamp:
22.05.2008 14:15:33 (11 years ago)
Author:
mdewsnip
Message:

(Adding new DB support) Added a sqltableexists() function to prevent errors re-creating the "data" table.

Location:
gsdl/trunk/lib
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/lib/sqliteclass.cpp

    r15636 r15637  
    6363  } 
    6464 
    65   if (mode == DB_WRITER_CREATE) 
     65  if ((mode == DB_WRITER || mode == DB_WRITER_CREATE) && !sqltableexists("data")) 
    6666  { 
    6767    sqlexec("CREATE TABLE data (key TEXT, value TEXT, PRIMARY KEY(key))"); 
     
    366366 
    367367 
     368// returns true if exists 
     369bool sqliteclass::sqltableexists(const text_t &table_name) 
     370{ 
     371  text_t sql_cmd = "SELECT * FROM sqlite_master WHERE tbl_name='" + table_name + "'"; 
     372  vector<text_tmap> sql_results; 
     373  if (!sqlgetarray(sql_cmd, sql_results) || sql_results.size() == 0) 
     374  { 
     375    return false; 
     376  } 
     377 
     378  return true; 
     379} 
     380 
     381 
    368382// sleep for the given number of milliseconds 
    369383void sleep(int m) 
  • gsdl/trunk/lib/sqliteclass.h

    r15631 r15637  
    6363            text_t &key, text_t &value); 
    6464 
     65  bool sqlexec (const text_t &sql_cmd); 
    6566  bool sqlgetarray (const text_t &sql_cmd, vector<text_tmap> &sql_results); 
    66   bool sqlexec (const text_t &sql_cmd); 
     67  bool sqltableexists (const text_t &table_name); 
    6768}; 
    6869