29#include <sptk5/sptk.h>
33#include <sptk5/db/PoolDatabaseConnection.h>
47class SP_EXPORT SQLite3Connection
48 :
public PoolDatabaseConnection
57 explicit SQLite3Connection(
const String& connectionString =
"", std::chrono::seconds connectTimeout = std::chrono::seconds(60));
62 ~SQLite3Connection()
override =
default;
67 String nativeConnectionString()
const override;
72 void closeDatabase()
override;
77 bool active()
const override;
82 DBHandle handle()
const override;
87 String driverDescription()
const override;
99 static std::map<SQLite3Connection*, std::shared_ptr<SQLite3Connection>> s_sqlite3Connections;
105 void driverBeginTransaction()
override;
111 void driverEndTransaction(
bool commit)
override;
117 String queryError(
const Query* query)
const override;
122 void queryAllocStmt(Query* query)
override;
127 void queryFreeStmt(Query* query)
override;
132 void queryCloseStmt(Query* query)
override;
137 void queryPrepare(Query* query)
override;
142 void queryExecute(Query* query)
override;
143 void queryColAttributes(Query* query, int16_t column, int16_t descType, int32_t& value)
override;
144 void queryColAttributes(Query* query, int16_t column, int16_t descType,
char* buff,
int len)
override;
148 int queryColCount(Query* query)
override;
153 void queryBindParameters(Query* query)
override;
158 void queryOpen(Query* query)
override;
163 void queryFetch(Query* query)
override;
168 sqlite3* connection()
170 return m_connect.get();
177 void _openDatabase(
const String& connectionString =
"")
override;
187 void _executeBatchSQL(
const sptk::Strings& batchSQL, Strings* errors)
override;
190 using SQLHSTMT = sqlite3_stmt*;
191 using SQLHDBC = sqlite3*;
193 mutable std::mutex m_mutex;
194 std::shared_ptr<sqlite3> m_connect;
195 void bindParameter(
const Query* query, uint32_t paramNumber)
const;
197 void closeAndClean();
198 int transformDateTimeParameter(sqlite3_stmt* stmt, QueryParameter* param,
short paramBindNumber)
const;
209SP_DRIVER_EXPORT [[maybe_unused]]
void* sqlite3_create_connection(
const char* connectionString,
size_t connectionTimeoutSeconds);
210SP_DRIVER_EXPORT [[maybe_unused]]
void sqlite3_destroy_connection(
void* connection);
DatabaseObjectType
Definition: PoolDatabaseConnection.h:70