]> git.phdru.name Git - m_librarian.git/commitdiff
Speedup SQLite connection
authorOleg Broytman <phd@phdru.name>
Thu, 24 Dec 2015 14:21:11 +0000 (17:21 +0300)
committerOleg Broytman <phd@phdru.name>
Thu, 24 Dec 2015 14:21:11 +0000 (17:21 +0300)
But increase the risk of loosing data.

m_librarian/db.py

index 6888ab8d418fe7f0c3845d244c95daa7f5e18a28..9a5eb0af3e65dd95c5b0a2045e6b2c892ed51b2b 100755 (executable)
@@ -40,7 +40,15 @@ if not db_uri:
 
     db_uri = 'sqlite://%s' % db_file.replace(os.sep, '/')
 
-sqlhub.processConnection = connectionForURI(db_uri)
+
+sqlhub.processConnection = connection = connectionForURI(db_uri)
+
+if connection.dbName == 'sqlite':
+    # Speedup SQLite connection
+    connection.query("PRAGMA synchronous=OFF")
+    connection.query("PRAGMA count_changes=OFF")
+    connection.query("PRAGMA journal_mode=MEMORY")
+    connection.query("PRAGMA temp_store=MEMORY")
 
 
 class Author(SQLObject):