prevent wrong spliting of db

This commit is contained in:
Yann Leboulanger 2010-01-29 19:02:54 +01:00
parent e86d1feeb2
commit 7a07d32b49
1 changed files with 5 additions and 0 deletions

View File

@ -890,9 +890,14 @@ class OptionsParser:
con = sqlite.connect(logger.LOG_DB_FILE)
os.chdir(back)
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)
for table in ('caps_cache', 'rooms_last_message_time', 'roster_entry',
'roster_group', 'transports_cache'):
if table not in tables:
continue
try:
cur.executescript(
'INSERT INTO cache.%s SELECT * FROM %s;' % (table, table))