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