mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #615
This commit is contained in:
parent
20bb195fbc
commit
7ec93d9f43
@ -75,7 +75,7 @@ def _connect(path):
|
|||||||
conn = sqlite.connect(path, detect_types=sqlite.PARSE_DECLTYPES|sqlite.PARSE_COLNAMES)
|
conn = sqlite.connect(path, detect_types=sqlite.PARSE_DECLTYPES|sqlite.PARSE_COLNAMES)
|
||||||
conn.row_factory = lambda cursor, row : list(row)
|
conn.row_factory = lambda cursor, row : list(row)
|
||||||
conn.create_aggregate('concat', 1, Concatenate)
|
conn.create_aggregate('concat', 1, Concatenate)
|
||||||
title_pat = re.compile('^(A|The|An\s+)', re.IGNORECASE)
|
title_pat = re.compile('^(A|The|An)\s+', re.IGNORECASE)
|
||||||
def title_sort(title):
|
def title_sort(title):
|
||||||
match = title_pat.search(title)
|
match = title_pat.search(title)
|
||||||
if match:
|
if match:
|
||||||
@ -777,6 +777,13 @@ ALTER TABLE books ADD COLUMN isbn TEXT DEFAULT "" COLLATE NOCASE;
|
|||||||
conn.execute('pragma user_version=9')
|
conn.execute('pragma user_version=9')
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def upgrade_version9(conn):
|
||||||
|
for id, title in conn.execute('SELECT id, title FROM books').fetchall():
|
||||||
|
conn.execute('UPDATE books SET title=? WHERE id=?', (title, id))
|
||||||
|
conn.execute('pragma user_version=10')
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
global _lock_file
|
global _lock_file
|
||||||
import os
|
import os
|
||||||
@ -792,22 +799,16 @@ ALTER TABLE books ADD COLUMN isbn TEXT DEFAULT "" COLLATE NOCASE;
|
|||||||
self.data = []
|
self.data = []
|
||||||
if self.user_version == 0: # No tables have been created
|
if self.user_version == 0: # No tables have been created
|
||||||
LibraryDatabase.create_version1(self.conn)
|
LibraryDatabase.create_version1(self.conn)
|
||||||
if self.user_version == 1: # Upgrade to 2
|
i = 0
|
||||||
LibraryDatabase.upgrade_version1(self.conn)
|
while True:
|
||||||
if self.user_version == 2: # Upgrade to 3
|
i += 1
|
||||||
LibraryDatabase.upgrade_version2(self.conn)
|
func = getattr(LibraryDatabase, 'upgrade_version%d'%i, None)
|
||||||
if self.user_version == 3: # Upgrade to 4
|
if func is None:
|
||||||
LibraryDatabase.upgrade_version3(self.conn)
|
break
|
||||||
if self.user_version == 4: # Upgrade to 5
|
if self.user_version == i:
|
||||||
LibraryDatabase.upgrade_version4(self.conn)
|
print 'Upgrading database from version: %d'%i
|
||||||
if self.user_version == 5: # Upgrade to 6
|
func(self.conn)
|
||||||
LibraryDatabase.upgrade_version5(self.conn)
|
|
||||||
if self.user_version == 6: # Upgrade to 7
|
|
||||||
LibraryDatabase.upgrade_version6(self.conn)
|
|
||||||
if self.user_version == 7: # Upgrade to 8
|
|
||||||
LibraryDatabase.upgrade_version7(self.conn)
|
|
||||||
if self.user_version == 8: # Upgrade to 9
|
|
||||||
LibraryDatabase.upgrade_version8(self.conn)
|
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
# global _lock_file
|
# global _lock_file
|
||||||
|
Loading…
x
Reference in New Issue
Block a user