Set sqlite to serialized mode.

This commit is contained in:
Relintai 2022-12-18 18:41:11 +01:00
parent a19be9b170
commit 6fdcd0e7c0
2 changed files with 11 additions and 10 deletions

View File

@ -37,13 +37,10 @@ def configure(env):
def _configure(env): def _configure(env):
#env.ParseConfig("pkg-config sqlite3 --cflags --libs") #env.ParseConfig("pkg-config sqlite3 --cflags --libs")
env.Append(CPPDEFINES=["SQLITE_PRESENT"]) #env.Append(CPPDEFINES=[("SQLITE_THREADSAFE", 1)])
# Link those statically for portability #env.Append(LINKFLAGS=["-ldl"])
#if env["use_static_cpp"]: pass
#env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"])
env.Append(LINKFLAGS=["-ldl"])
def get_doc_classes(): def get_doc_classes():

View File

@ -27,15 +27,19 @@ Ref<TableBuilder> SQLite3DatabaseConnection::get_table_builder() {
} }
void SQLite3DatabaseConnection::database_connect(const String &connection_str) { void SQLite3DatabaseConnection::database_connect(const String &connection_str) {
int ret = sqlite3_config(SQLITE_CONFIG_MULTITHREAD); int ret = sqlite3_config(SQLITE_CONFIG_SERIALIZED);
if (ret != SQLITE_OK) { //if (ret != SQLITE_OK) {
ERR_PRINT("SQLITE3 multithreading is not supported!\n"); //ERR_PRINT("SQLITE3 multithreading is not supported!\n");
} //}
//CharString cstr = connection_str.ascii(); //CharString cstr = connection_str.ascii();
CharString cstr = connection_str.utf8(); CharString cstr = connection_str.utf8();
ret = sqlite3_open(cstr.get_data(), &conn); ret = sqlite3_open(cstr.get_data(), &conn);
if (ret != SQLITE_OK) {
ERR_PRINT(vformat("SQLITE3 database_connect failed! code: %d !", ret));
}
} }
Ref<QueryResult> SQLite3DatabaseConnection::query(const String &query) { Ref<QueryResult> SQLite3DatabaseConnection::query(const String &query) {