Commit 242176c1 authored by Pavel Vainerman's avatar Pavel Vainerman

(SQLite): добавил использование sqlite3_busy_timeout();

parent 49b07fcd
...@@ -74,6 +74,7 @@ bool SQLiteInterface::connect( const string dbfile, bool create ) ...@@ -74,6 +74,7 @@ bool SQLiteInterface::connect( const string dbfile, bool create )
return false; return false;
} }
setOperationTimeout(opTimeout);
connected = true; connected = true;
return true; return true;
} }
...@@ -89,6 +90,13 @@ bool SQLiteInterface::close() ...@@ -89,6 +90,13 @@ bool SQLiteInterface::close()
return true; return true;
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
void SQLiteInterface::setOperationTimeout( timeout_t msec )
{
opTimeout = msec;
if( db )
sqlite3_busy_timeout(db,opTimeout);
}
// -----------------------------------------------------------------------------------------
bool SQLiteInterface::insert( const string q ) bool SQLiteInterface::insert( const string q )
{ {
if( !db ) if( !db )
......
...@@ -33,11 +33,11 @@ ...@@ -33,11 +33,11 @@
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class SQLiteResult; class SQLiteResult;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Памятка:
// Включение режима для журнала - "вести в памяти" (чтобы поберечь CompactFlash) // Включение режима для журнала - "вести в памяти" (чтобы поберечь CompactFlash)
// PRAGMA journal_mode = MEMORY // PRAGMA journal_mode = MEMORY
// //
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class SQLiteInterface class SQLiteInterface
{ {
public: public:
...@@ -50,7 +50,7 @@ class SQLiteInterface ...@@ -50,7 +50,7 @@ class SQLiteInterface
bool isConnection(); bool isConnection();
bool ping(); // проверка доступности БД bool ping(); // проверка доступности БД
inline void setOperationTimeout( timeout_t msec ){ opTimeout = msec; } void setOperationTimeout( timeout_t msec );
inline timeout_t getOperationTimeout(){ return opTimeout; } inline timeout_t getOperationTimeout(){ return opTimeout; }
inline void setOperationCheckPause( timeout_t msec ){ opCheckPause = msec; } inline void setOperationCheckPause( timeout_t msec ){ opCheckPause = msec; }
......
...@@ -5,6 +5,9 @@ dbname=test.db ...@@ -5,6 +5,9 @@ dbname=test.db
[ -n "$1" ] && dbname="$1" [ -n "$1" ] && dbname="$1"
sqlite3 $dbname <<"_EOF_" sqlite3 $dbname <<"_EOF_"
PRAGMA foreign_keys=ON;
DROP TABLE IF EXISTS main_history; DROP TABLE IF EXISTS main_history;
CREATE TABLE main_history ( CREATE TABLE main_history (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
......
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