Skip to content

Commit

Permalink
Put double quotes around table name in copy statement
Browse files Browse the repository at this point in the history
Necessary in certain situations, e.g. table name has capital letters
  • Loading branch information
austinweisgrau committed Sep 20, 2024
1 parent 7795783 commit 71fdf0e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion parsons/databases/postgres/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def copy(
self.query_with_connection(sql, connection, commit=False)
logger.info(f"{table_name} created.")

sql = f"COPY {table_name} ({','.join(tbl.columns)}) FROM STDIN CSV HEADER;"
sql = f"""COPY "{table_name}" ("{'","'.join(tbl.columns)}") FROM STDIN CSV HEADER;"""

with self.cursor(connection) as cursor:
cursor.copy_expert(sql, open(tbl.to_csv(), "r"))
Expand Down

0 comments on commit 71fdf0e

Please sign in to comment.