Commit 11c8f221 authored by Pavel Vainerman's avatar Pavel Vainerman

(SQLite): немного подправил интерфейс..

parent 272e10ba
...@@ -44,16 +44,12 @@ opCheckPause(50) ...@@ -44,16 +44,12 @@ opCheckPause(50)
SQLiteInterface::~SQLiteInterface() SQLiteInterface::~SQLiteInterface()
{ {
close(); close();
if( db )
delete db; delete db;
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
bool SQLiteInterface::ping() bool SQLiteInterface::connect( const string dbfile, bool create )
{
return db && ( sqlite3_db_status(db,0,NULL,NULL,0) == SQLITE_OK );
}
// -----------------------------------------------------------------------------------------
bool SQLiteInterface::connect( const string& dbfile, bool create )
{ {
// т.к. sqlite3 по умолчанию, создаёт файл при открытии, то проверим "сами" // т.к. sqlite3 по умолчанию, создаёт файл при открытии, то проверим "сами"
// if( !create && !UniSetTypes::file_exist(dbfile) ) // if( !create && !UniSetTypes::file_exist(dbfile) )
...@@ -73,7 +69,6 @@ bool SQLiteInterface::connect( const string& dbfile, bool create ) ...@@ -73,7 +69,6 @@ bool SQLiteInterface::connect( const string& dbfile, bool create )
return false; return false;
} }
setOperationTimeout(opTimeout);
connected = true; connected = true;
return true; return true;
} }
...@@ -89,14 +84,7 @@ bool SQLiteInterface::close() ...@@ -89,14 +84,7 @@ bool SQLiteInterface::close()
return true; return true;
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
void SQLiteInterface::setOperationTimeout( timeout_t msec ) bool SQLiteInterface::insert( const string q )
{
opTimeout = msec;
if( db )
sqlite3_busy_timeout(db,opTimeout);
}
// -----------------------------------------------------------------------------------------
bool SQLiteInterface::insert( const string& q )
{ {
if( !db ) if( !db )
return false; return false;
...@@ -133,7 +121,7 @@ bool SQLiteInterface::checkResult( int rc ) ...@@ -133,7 +121,7 @@ bool SQLiteInterface::checkResult( int rc )
return true; return true;
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
SQLiteResult SQLiteInterface::query( const string& q ) SQLiteResult SQLiteInterface::query( const string q )
{ {
if( !db ) if( !db )
return SQLiteResult(); return SQLiteResult();
......
...@@ -21,6 +21,10 @@ INSERT INTO main_history VALUES(NULL,0,0,0,100,20.3,1,0); ...@@ -21,6 +21,10 @@ INSERT INTO main_history VALUES(NULL,0,0,0,100,20.3,1,0);
INSERT INTO main_history VALUES(NULL,0,0,0,101,20.65,1,0); INSERT INTO main_history VALUES(NULL,0,0,0,101,20.65,1,0);
INSERT INTO main_history VALUES(NULL,0,0,0,102,20.7,1,0); INSERT INTO main_history VALUES(NULL,0,0,0,102,20.7,1,0);
INSERT INTO main_history VALUES(NULL,0,0,0,103,20.1,1,0); INSERT INTO main_history VALUES(NULL,0,0,0,103,20.1,1,0);
INSERT INTO main_history VALUES(NULL,0,0,0,105,20.3,1,0);
INSERT INTO main_history VALUES(NULL,0,0,0,106,20.65,1,0);
INSERT INTO main_history VALUES(NULL,0,0,0,107,20233.7,1,0);
INSERT INTO main_history VALUES(NULL,0,0,0,108,245560.67671,1,0);
_EOF_ _EOF_
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment