Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sqlite3
- # conn = sqlite3.connect("/home/herles1/Desktop/main.db")
- # conn2 = sqlite3.connect("/home/herles1/Desktop/my.db")
- conn = sqlite3.connect("/home/sid/.Skype/testmasterut/main.db")
- conn2 = sqlite3.connect("/home/sid/skp/main.db")
- createLogTableSql = """
- CREATE TABLE IF NOT EXISTS sid_log(s_id INTEGER PRIMARY KEY,
- s_author TEXT,s_timestamp INTEGER,
- s_editedby TEXT,s_edited_timestamp INTEGER,s_body_xml TEXT)
- """
- conn2.execute(createLogTableSql)
- conn2.commit()
- selectLog = """ select id,author,timestamp,edited_by,edited_timestamp,body_xml from Messages """
- skype_table = conn.execute(selectLog)
- insertToLogTable = """
- INSERT INTO sid_log(s_id,s_author,s_timestamp,s_editedby,s_edited_timestamp,s_body_xml) VALUES(?,?,?,?,?,?)
- """
- for row in skype_table:
- conn2.execute(insertToLogTable, (row[0],row[1],row[2],row[3],row[4],row[5]))
- conn2.commit()
- print "Table to save the old messages has been created"
- selectLogID = """ select s_id from sid_log """
- while True:
- original_table_ids = conn2.execute(selectLogID)
- id_list = []
- for row in original_table_ids:
- id_list.append(row[0])
- newMessages = "SELECT id,author,timestamp,edited_by,edited_timestamp,body_xml FROM Messages WHERE id NOT IN ({}) AND edited_by IS NULL AND edited_timestamp IS NULL".format(','.join(['?']*len(id_list)))
- newMessagesRows = conn.execute(newMessages, id_list)
- for row in newMessagesRows:
- conn2.execute(insertToLogTable, row[0],row[1],row[2],row[3],row[4],row[5])
- conn2.commit()
- original_table_ids = conn2.execute(selectLogID)
- id_list = []
- for row in original_table_ids:
- id_list.append(row[0])
- editedMessages = "SELECT id,author,timestamp,edited_by,edited_timestamp,body_xml FROM Messages WHERE id IN ({}) AND edited_by IS NOT NULL AND edited_timestamp IS NOT NULL".format(','.join(['?']*len(id_list)))
- editedMessagesRows = conn.execute(editedMessages, id_list)
- for row in editedMessagesRows:
- queryString = "SELECT * FROM sid_log WHERE s_id IN (%d)" % org_row[0]
- original_message = conn2.execute(queryString)
- for org_row in original_message:
- print "Message edited from", org_row[5], "to", row[5]
- conn.close()
- conn2.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement