@@ -19,9 +19,9 @@ def make_session(connection_string):
1919
2020class DBDiff (object ):
2121
22- def __init__ (self , firstdb , seconddb , chunk_size = 10000 , count_only = False , exclude_tables = "" ):
22+ def __init__ (self , firstdb , seconddb , schema , chunk_size = 10000 , count_only = False , exclude_tables = "" ):
2323 firstsession , firstengine = make_session (firstdb )
24- secondsession , secondengine = make_session (seconddb )
24+ secondsession , secondengine = make_session (seconddb , )
2525 self .firstsession = firstsession
2626 self .firstengine = firstengine
2727 self .secondsession = secondsession
@@ -33,6 +33,7 @@ def __init__(self, firstdb, seconddb, chunk_size=10000, count_only=False, exclud
3333 self .chunk_size = int (chunk_size )
3434 self .count_only = count_only
3535 self .exclude_tables = exclude_tables .split (',' )
36+ self .schema = schema
3637
3738 def diff_table_data (self , tablename ):
3839 try :
@@ -62,7 +63,7 @@ def diff_table_data(self, tablename):
6263 SELECT md5(array_agg(md5((t.*)::varchar))::varchar)
6364 FROM (
6465 SELECT *
65- FROM { tablename }
66+ FROM { self . schema } . { tablename }
6667 ORDER BY { pk } limit :row_limit offset :row_offset
6768 ) AS t;
6869 """
@@ -91,7 +92,7 @@ def get_all_sequences(self):
9192 self .firstsession .execute (GET_SEQUENCES_SQL ).fetchall ()]
9293
9394 def diff_sequence (self , seq_name ):
94- GET_SEQUENCES_VALUE_SQL = f"SELECT last_value FROM { seq_name } ;"
95+ GET_SEQUENCES_VALUE_SQL = f"SELECT last_value FROM { self . schema } . { seq_name } ;"
9596
9697 try :
9798 firstvalue = \
@@ -141,7 +142,7 @@ def diff_all_table_data(self):
141142 with warnings .catch_warnings ():
142143 warnings .simplefilter ("ignore" , category = sa_exc .SAWarning )
143144 tables = sorted (
144- self .firstinspector .get_table_names (schema = "public" ))
145+ self .firstinspector .get_table_names (schema = self . schema ))
145146 for table in tables :
146147 if table in self .exclude_tables :
147148 print (bold (yellow (f"Ignoring table { table } " )))
0 commit comments