From 71fdf0e063c4443f9a17f079af1be1314e48511b Mon Sep 17 00:00:00 2001 From: Austin Weisgrau Date: Fri, 20 Sep 2024 16:31:29 -0700 Subject: [PATCH] Put double quotes around table name in copy statement Necessary in certain situations, e.g. table name has capital letters --- parsons/databases/postgres/postgres.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parsons/databases/postgres/postgres.py b/parsons/databases/postgres/postgres.py index 6b90adfe11..f92fd14ada 100644 --- a/parsons/databases/postgres/postgres.py +++ b/parsons/databases/postgres/postgres.py @@ -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"))