Skip to content

Commit

Permalink
added print statements
Browse files Browse the repository at this point in the history
  • Loading branch information
COMMANDO2406 committed Jul 10, 2024
1 parent ef4a023 commit f25c7e3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def import_data(self):

columns = [f"{col.strip()} varchar(255)" for col in column_names.split(",")]
create_table_query = f"CREATE TABLE IF NOT EXISTS {table_name} ({', '.join(columns)})"
# print(f"Create Table Query: {create_table_query}")
cur.execute(create_table_query)

with open(csv_file_path, "r") as file:
Expand All @@ -107,12 +108,15 @@ def import_data(self):
for row in reader:
insert_query = f"INSERT INTO {table_name} ({', '.join(column_names.split(','))}) values ({', '.join(['%s'] * len(row))})"
values = tuple(row)
# print(f"Insert Query: {insert_query}, Values: {values}")
cur.execute(insert_query, values)

con.commit()
con.close()
print("Data imported successfully.")
QMessageBox.information(self, 'Success', 'Data imported successfully.')
except mysql.connector.Error as err:
print(f"Error: {err}")
QMessageBox.critical(self, 'Error', f"Error: {err}")

if __name__ == '__main__':
Expand Down

0 comments on commit f25c7e3

Please sign in to comment.