prevent wrong spliting of db
This commit is contained in:
parent
e86d1feeb2
commit
7a07d32b49
|
@ -890,9 +890,14 @@ class OptionsParser:
|
||||||
con = sqlite.connect(logger.LOG_DB_FILE)
|
con = sqlite.connect(logger.LOG_DB_FILE)
|
||||||
os.chdir(back)
|
os.chdir(back)
|
||||||
cur = con.cursor()
|
cur = con.cursor()
|
||||||
|
cur.execute('''SELECT name FROM sqlite_master WHERE type = 'table';''')
|
||||||
|
tables = cur.fetchall() # we get [(u'jids',), (u'unread_messages',), ...
|
||||||
|
tables = [t[0] for t in tables]
|
||||||
cur.execute("ATTACH DATABASE '%s' AS cache" % logger.CACHE_DB_PATH)
|
cur.execute("ATTACH DATABASE '%s' AS cache" % logger.CACHE_DB_PATH)
|
||||||
for table in ('caps_cache', 'rooms_last_message_time', 'roster_entry',
|
for table in ('caps_cache', 'rooms_last_message_time', 'roster_entry',
|
||||||
'roster_group', 'transports_cache'):
|
'roster_group', 'transports_cache'):
|
||||||
|
if table not in tables:
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
cur.executescript(
|
cur.executescript(
|
||||||
'INSERT INTO cache.%s SELECT * FROM %s;' % (table, table))
|
'INSERT INTO cache.%s SELECT * FROM %s;' % (table, table))
|
||||||
|
|
Loading…
Reference in New Issue