@@ -54,7 +54,7 @@ def fill_table(o_engine_conn, d_engine_conn, table_name, chunk_size):
5454 except Exception as e :
5555 logger .error (f"Need to create { table_name } table before filling it" , e )
5656 raise Exception (f"Need to create { table_name } table before filling it" )
57-
57+
5858 dpk = [c for c in d_table .primary_key .columns ][0 ]
5959 count = o_engine .execute (select ([func .count (pk )])).scalar ()
6060 d_count = d_engine .execute (select ([func .count (dpk )])).scalar ()
@@ -67,7 +67,7 @@ def fill_table(o_engine_conn, d_engine_conn, table_name, chunk_size):
6767 elif count != d_count and d_count != 0 :
6868 q = select ([d_table ]).order_by (dpk .desc ()).limit (1 )
6969 res = d_engine .execute (q )
70- next_id = res .fetchone ().__getitem__ (dpk .name )
70+ last_id = res .fetchone ().__getitem__ (dpk .name )
7171 first_it = False
7272
7373 # table has a composite pk (usualy a bad design choice).
@@ -99,13 +99,13 @@ def fill_table(o_engine_conn, d_engine_conn, table_name, chunk_size):
9999 while True :
100100 q = select ([table ]).order_by (pk ).limit (chunk_size )
101101 if not first_it :
102- q = q .where (pk > next_id )
102+ q = q .where (pk > last_id )
103103 else :
104104 first_it = False
105105 res = o_engine .execute (q )
106106 data = res .fetchall ()
107107 if len (data ):
108- next_id = data [- 1 ].__getitem__ (pk .name )
108+ last_id = data [- 1 ].__getitem__ (pk .name )
109109 d_engine .execute (
110110 table .insert (),
111111 [
@@ -262,16 +262,12 @@ def __copy_schema(self):
262262
263263 table .indexes = set ()
264264
265- # TODO: Hacky. Fails when reflecting column/table comments so removing it.
266265 new_metadata_cols = ColumnCollection ()
267266 for col in table ._columns :
268- col .comment = None
269267 col = self .__fix_column_type (col , d_engine .name )
270- # be sure that no column has auto-increment
271268 col .autoincrement = False
272269 new_metadata_cols .add (col )
273270 table .columns = new_metadata_cols .as_immutable ()
274- table .comment = None
275271 new_metadata_tables [table_name ] = table
276272 metadata .tables = immutabledict (new_metadata_tables )
277273 metadata .create_all (d_engine )
0 commit comments