11import warnings
22
3- from fabulous .color import bold , green , red
3+ from fabulous .color import bold , green , red , yellow
44from halo import Halo
55from sqlalchemy import exc as sa_exc
66from sqlalchemy .engine import create_engine
@@ -19,7 +19,7 @@ def make_session(connection_string):
1919
2020class DBDiff (object ):
2121
22- def __init__ (self , firstdb , seconddb , chunk_size = 10000 , count_only = False ):
22+ def __init__ (self , firstdb , seconddb , chunk_size = 10000 , count_only = False , exclude_tables = "" ):
2323 firstsession , firstengine = make_session (firstdb )
2424 secondsession , secondengine = make_session (seconddb )
2525 self .firstsession = firstsession
@@ -32,6 +32,7 @@ def __init__(self, firstdb, seconddb, chunk_size=10000, count_only=False):
3232 self .secondinspector = inspect (secondengine )
3333 self .chunk_size = int (chunk_size )
3434 self .count_only = count_only
35+ self .exclude_tables = exclude_tables .split (',' )
3536
3637 def diff_table_data (self , tablename ):
3738 try :
@@ -142,6 +143,9 @@ def diff_all_table_data(self):
142143 tables = sorted (
143144 self .firstinspector .get_table_names (schema = "public" ))
144145 for table in tables :
146+ if table in self .exclude_tables :
147+ print (bold (yellow (f"Ignoring table { table } " )))
148+ continue
145149 with Halo (
146150 text = f"Analysing table { table } . "
147151 f"[{ tables .index (table ) + 1 } /{ len (tables )} ]" ,
0 commit comments