debug insert logs
This commit is contained in:
8
main.py
8
main.py
@@ -47,7 +47,7 @@ class DBConn:
|
|||||||
def write_to_database(self, tbl, column_data):
|
def write_to_database(self, tbl, column_data):
|
||||||
col_names = column_data.keys() # OrderedDict
|
col_names = column_data.keys() # OrderedDict
|
||||||
|
|
||||||
col_names = ', '.join(
|
col_names_placeholder = ', '.join(
|
||||||
[f"\"{x}\"" for x in col_names]
|
[f"\"{x}\"" for x in col_names]
|
||||||
)
|
)
|
||||||
value_placeholders = ', '.join(
|
value_placeholders = ', '.join(
|
||||||
@@ -69,10 +69,12 @@ class DBConn:
|
|||||||
for new_col in not_found:
|
for new_col in not_found:
|
||||||
self.cur.execute(f"alter table \"{tbl}\" add column \"{new_col}\" text")
|
self.cur.execute(f"alter table \"{tbl}\" add column \"{new_col}\" text")
|
||||||
|
|
||||||
print(f"added {not_found} cols to {tbl}")
|
print(f"added new cols {', '.join(not_found)} to {tbl}")
|
||||||
self.table_mapping[tbl] = column_data
|
self.table_mapping[tbl] = column_data
|
||||||
|
|
||||||
sql = f"insert into \"{tbl}\" ({col_names}) values({value_placeholders})"
|
sql = f"insert into \"{tbl}\" ({col_names_placeholder}) values({value_placeholders})"
|
||||||
|
if args.debug:
|
||||||
|
print(f"insert sql = {sql}")
|
||||||
self.cur.execute(sql, values)
|
self.cur.execute(sql, values)
|
||||||
|
|
||||||
def make_csv_from_tables(self, prefix=''):
|
def make_csv_from_tables(self, prefix=''):
|
||||||
|
|||||||
Reference in New Issue
Block a user