def test_compare_different_sqlite_master_table_def(self): self.db1.cursor().execute("create table stocks (date text, trans text, symbol text, qty real, price real);") self.db2.cursor().execute("create table stocks (date text, symbol text, qty real, price real);") self.assertEqual(diff.table_column_diff(self.db1.cursor(), self.db2.cursor()), [((u'table', u'stocks', u'stocks', 2, u'CREATE TABLE stocks (date text, trans text, symbol text, qty real, price real)'), (u'table', u'stocks', u'stocks', 2, u'CREATE TABLE stocks (date text, symbol text, qty real, price real)'))]) self.db1.cursor().execute("create table bonds (date text, trans text, symbol text, qty real, price real);") self.assertEqual(diff.table_column_diff(self.db1.cursor(), self.db2.cursor()), [((u'table', u'stocks', u'stocks', 2, u'CREATE TABLE stocks (date text, trans text, symbol text, qty real, price real)'), (u'table', u'stocks', u'stocks', 2, u'CREATE TABLE stocks (date text, symbol text, qty real, price real)'))])
import sqlite3 import sys from nmj.tables import ALL_TABLES from sqlite3_diff import diff_table, table_column_diff from sqlite3_diff.format import format_table_diff def get_connection_and_cursor(db_file): connection = sqlite3.connect(db_file) connection.isolation_level = "DEFERRED" connection.text_factory = str cursor = connection.cursor() return connection, cursor db1, cur1 = get_connection_and_cursor( "/home/ecolleu/dev/nmjv2/series.orig/nmj_database/media.db") db2, cur2 = get_connection_and_cursor( "/home/ecolleu/dev/nmjv2/series/nmj_database/media.db") for table in ALL_TABLES: diff = table_column_diff(cur1, cur2) print(diff)
def test_compare_same_sqlite_master_table_def(self): self.__create_stocks_bonds() #Both tables are the same self.assertFalse(diff.table_column_diff(self.db1.cursor(), self.db2.cursor()))