[Gcblue-commits] gcb_wx/include/database tcAccountDatabase.h,1.1,1.2 tcDBObjSerializerSql.h,1.4,1.5
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-09-16 00:16:17
|
Update of /cvsroot/gcblue/gcb_wx/include/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24731/include/database Modified Files: tcAccountDatabase.h tcDBObjSerializerSql.h tcSqlReader.h Log Message: Upgraded to Sqlite 3.2.5 Index: tcDBObjSerializerSql.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcDBObjSerializerSql.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcDBObjSerializerSql.h 1 Jun 2005 00:13:25 -0000 1.4 --- tcDBObjSerializerSql.h 16 Sep 2005 00:16:08 -0000 1.5 *************** *** 31,35 **** #include <fstream> #include <string> ! #include "sqlite/sqlite_plus.h" #include "database/tcSqlReader.h" --- 31,35 ---- #include <fstream> #include <string> ! #include "sqlite/sqlite3x.hpp" #include "database/tcSqlReader.h" *************** *** 39,42 **** --- 39,47 ---- #endif + using sqlite3x::sqlite3_reader; + using sqlite3x::sqlite3_command; + using sqlite3x::sqlite3_connection; + + /** * Saves/loads objects of class T from database. *************** *** 54,58 **** { public: ! tcDBObjSerializerSql(tcDatabase* db, sqlite::connection& con, std::string s) : database(db), sqlConn(con), tableName(s) {} bool Load(); --- 59,63 ---- { public: ! tcDBObjSerializerSql(tcDatabase* db, sqlite3x::sqlite3_connection& con, std::string s) : database(db), sqlConn(con), tableName(s) {} bool Load(); *************** *** 61,65 **** tcDatabase* database; std::string tableName; ! sqlite::connection& sqlConn; }; --- 66,70 ---- tcDatabase* database; std::string tableName; ! sqlite3x::sqlite3_connection& sqlConn; }; *************** *** 72,78 **** { // check if the table exists, abort if it doesn't ! string countStr = ! sqlConn.executescalar("select count(*) from sqlite_master where name='%s';", tableName.c_str()); if (countStr == "0") --- 77,83 ---- { // check if the table exists, abort if it doesn't ! wxString command = wxString::Format("select count(*) from sqlite_master where name='%s';", tableName.c_str()); + string countStr = sqlConn.executestring(command.c_str()); if (countStr == "0") *************** *** 97,105 **** try { ! sqlite::reader tableInfo = sqlConn.executereader( ! "pragma table_info(%s);", tableName.c_str() ); ! sqlite::reader tableData = sqlConn.executereader( ! "select * from %s;", tableName.c_str()); tcSqlReader sqlReader(tableInfo, tableData); --- 102,114 ---- try { ! wxString command = wxString::Format("pragma table_info(%s);", tableName.c_str()); ! sqlite3_command sqlCmd(sqlConn, command.c_str()); ! sqlite3_reader tableInfo = sqlCmd.executereader(); ! ! command = wxString::Format("select * from %s;", tableName.c_str()); ! ! sqlite3_command sqlCmd2(sqlConn, command.c_str()); ! sqlite3_reader tableData = sqlCmd2.executereader(); tcSqlReader sqlReader(tableInfo, tableData); *************** *** 139,150 **** { // delete table if it exists ! string countStr = sqlConn.executescalar( ! "select count(*) from sqlite_master where name='%s';", ! tableName.c_str() ); if (countStr != "0") { ! sqlConn.executenonquery("drop table %s;", tableName.c_str()); } --- 148,160 ---- { // delete table if it exists ! wxString command = wxString::Format("select count(*) from sqlite_master where name='%s';", ! tableName.c_str()); ! string countStr = sqlConn.executestring(command.c_str()); if (countStr != "0") { ! command = wxString::Format("drop table %s;", tableName.c_str()); ! sqlConn.executenonquery(command.c_str()); } *************** *** 158,165 **** fprintf(stdout, "column str: (%s)\n", columnString.c_str()); #endif ! ! sqlConn.executenonquery( ! "create table %s (%s);", tableName.c_str(), columnString.c_str()); } catch(exception &ex) --- 168,174 ---- fprintf(stdout, "column str: (%s)\n", columnString.c_str()); #endif ! command = wxString::Format("create table %s (%s);", tableName.c_str(), columnString.c_str()); + sqlConn.executenonquery(command.c_str()); } catch(exception &ex) *************** *** 189,196 **** fprintf(stdout, "value str: (%s)\n", valueString.c_str()); #endif ! ! sqlConn.executenonquery( ! "insert into %s values (%s);", tableName.c_str(), valueString.c_str()); } catch(exception &ex) --- 198,204 ---- fprintf(stdout, "value str: (%s)\n", valueString.c_str()); #endif ! wxString command = wxString::Format("insert into %s values (%s);", tableName.c_str(), valueString.c_str()); + sqlConn.executenonquery(command.c_str()); } catch(exception &ex) Index: tcAccountDatabase.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcAccountDatabase.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcAccountDatabase.h 6 May 2005 23:57:16 -0000 1.1 --- tcAccountDatabase.h 16 Sep 2005 00:16:08 -0000 1.2 *************** *** 28,34 **** class CMD5; ! namespace sqlite { ! class connection; } --- 28,34 ---- class CMD5; ! namespace sqlite3x { ! class sqlite3_connection; } *************** *** 111,115 **** static tcAccountDatabase* Get(); ///< singleton instance accessor private: ! sqlite::connection* accountDatabase; std::map<std::string, unsigned int> columnLookup; // for faster access of data CMD5* md5; --- 111,115 ---- static tcAccountDatabase* Get(); ///< singleton instance accessor private: ! sqlite3x::sqlite3_connection* accountDatabase; std::map<std::string, unsigned int> columnLookup; // for faster access of data CMD5* md5; Index: tcSqlReader.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcSqlReader.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcSqlReader.h 12 Jun 2005 20:46:27 -0000 1.4 --- tcSqlReader.h 16 Sep 2005 00:16:08 -0000 1.5 *************** *** 31,37 **** #include <map> ! namespace sqlite { ! class reader; } --- 31,37 ---- #include <map> ! namespace sqlite3x { ! class sqlite3_reader; } *************** *** 67,78 **** bool Read(); ! tcSqlReader(sqlite::reader& tableInfo, sqlite::reader& _data); ~tcSqlReader(); private: std::map<std::string, unsigned int> columnLookup; ! sqlite::reader& data; char buffer[128]; ///< internal buffer for formatting column names, watch overrun! ! void BuildColumnLookup(sqlite::reader& tableInfo); unsigned int LookupFieldIndex(const std::string& field); }; --- 67,78 ---- bool Read(); ! tcSqlReader(sqlite3x::sqlite3_reader& tableInfo, sqlite3x::sqlite3_reader& _data); ~tcSqlReader(); private: std::map<std::string, unsigned int> columnLookup; ! sqlite3x::sqlite3_reader& data; char buffer[128]; ///< internal buffer for formatting column names, watch overrun! ! void BuildColumnLookup(sqlite3x::sqlite3_reader& tableInfo); unsigned int LookupFieldIndex(const std::string& field); }; |