You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.6 KiB
61 lines
1.6 KiB
#ifndef _SQLITE_base_class_h_
|
|
#define _SQLITE_base_class_h_
|
|
|
|
#include "../../components/base/basicLogCollection.h"
|
|
#include "../../components/base/basicMutex.h"
|
|
#include "../../components/base/basicTypes.h"
|
|
// #include <mysql/mysql.h>
|
|
#include <sqlite3.h>
|
|
|
|
#ifndef SQLITE_BUSY_TIMEOUT_MS
|
|
// How long a statement waits for a lock held by another connection before failing with SQLITE_BUSY
|
|
#define SQLITE_BUSY_TIMEOUT_MS 2000
|
|
#endif
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
#define DEBUG_SQLITE_QUERIES
|
|
#endif
|
|
|
|
class SQLite_Connector
|
|
{
|
|
private:
|
|
|
|
basicLogCollection * m_pLog;
|
|
bool m_bIsConnected;
|
|
basicMutex m_mAccessMutex;
|
|
sqlite3 * m_pDBLink;
|
|
sqlite3_stmt * m_pResult;
|
|
// MYSQL_ROW m_pRow;
|
|
char m_pDBName[MAX_PATH];
|
|
int m_nFLAGS;
|
|
bool m_bPersistentConnection;
|
|
|
|
public:
|
|
|
|
SQLite_Connector();
|
|
SQLite_Connector(CSTR DBHost, CSTR DBUser, CSTR DBPassword, U16 Port = 3306);
|
|
SQLite_Connector(CSTR DBName, CSTR DBHost, CSTR DBUser, CSTR DBPassword, U16 Port = 3306);
|
|
// MySQL_Connector( char *LocalUnixSocket, char *DBUser, char* DBPassword );
|
|
virtual ~SQLite_Connector();
|
|
bool Connect(CSTR FileName, int AUX_FLAGS = SQLITE_OPEN_FULLMUTEX, bool Persistent = false);
|
|
|
|
CSTR escapeString(CSTR str);
|
|
CSTR escapeBinary(uint8_t * Data, uint32_t Size);
|
|
|
|
bool isConnected(void)
|
|
{
|
|
return m_bIsConnected;
|
|
}
|
|
|
|
uint64_t QueryID(CSTR QS);
|
|
bool SilentQuery(CSTR QS);
|
|
AAssoc * Query(CSTR QS, bool useCache = false);
|
|
void deleteResult(AAssoc *& R);
|
|
bool ReConnect(void);
|
|
bool Disconnect(void);
|
|
};
|
|
|
|
void deleteResult(AAssoc *& ptr);
|
|
// extern MySQL_Connector DBC;
|
|
|
|
#endif
|