]> git.phdru.name Git - m_librarian.git/commitdiff
VACUUM all tables after mass-insert
authorOleg Broytman <phd@phdru.name>
Fri, 25 Dec 2015 21:32:21 +0000 (00:32 +0300)
committerOleg Broytman <phd@phdru.name>
Fri, 25 Dec 2015 21:35:46 +0000 (00:35 +0300)
m_librarian/glst.py
m_librarian/inp.py

index 44ec6121cbeaf6038730f3a5f9c17abf0a99a0d4..b94381377e35072e98817665b18042cc2ac9c55a 100755 (executable)
@@ -48,7 +48,9 @@ def _import_glst():
         os.path.join(ml_dir, 'glst', 'genres_fb2.glst'))
     old_nonfb2, new_nonfb2 = import_glst_file(
         os.path.join(ml_dir, 'glst', 'genres_nonfb2.glst'))
-    sqlhub.processConnection.query("VACUUM %s" % Genre.sqlmeta.table)
+    connection = sqlhub.processConnection
+    if connection.dbName in ('postgres', 'sqlite'):
+        connection.query("VACUUM %s" % Genre.sqlmeta.table)
     return old_fb2 + old_nonfb2, new_fb2 + new_nonfb2
 
 
index db0a3d834baf41c5bb7a195a12047d2ceb07c3df..e99800a18e13d4ec3fc6ffcefa6915e5699b9642 100644 (file)
@@ -68,3 +68,7 @@ def import_inpx(path):
         inp = inpx.open(name)
         sqlhub.doInTransaction(import_inp, archive + '.zip', inp)
         inp.close()
+    connection = sqlhub.processConnection
+    if connection.dbName in ('postgres', 'sqlite'):
+        for table in Author, Book, Extension, Genre, Language:
+            connection.query("VACUUM %s" % table.sqlmeta.table)