]> git.phdru.name Git - m_librarian.git/blobdiff - m_librarian/db.py
Pass keywords parameters to insert_name
[m_librarian.git] / m_librarian / db.py
index 6888ab8d418fe7f0c3845d244c95daa7f5e18a28..c77e32fc554a092f18dfddaf6d782ce2efa0560b 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):
@@ -94,11 +102,11 @@ def init_db():
         return
 
 
-def insert_name(table, name):
+def insert_name(table, name, **kw):
     try:
         return table.byName(name)
     except SQLObjectNotFound:
-        return table(name=name, count=0)
+        return table(name=name, count=0, **kw)
 
 
 def test():