Skip to content

Commit

Permalink
fix: Use literals when querying information_schema
Browse files Browse the repository at this point in the history
  • Loading branch information
kukushking committed Jul 11, 2023
1 parent fd07424 commit 45848df
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions awswrangler/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ def _drop_table(cursor: "pg8000.Cursor", schema: Optional[str], table: str) -> N


def _does_table_exist(cursor: "pg8000.Cursor", schema: Optional[str], table: str) -> bool:
schema_str = f"TABLE_SCHEMA = '{pg8000_native.identifier(schema)}' AND" if schema else ""
schema_str = f"TABLE_SCHEMA = {pg8000_native.literal(schema)} AND" if schema else ""
cursor.execute(
f"SELECT true WHERE EXISTS ("
f"SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE "
f"{schema_str} TABLE_NAME = '{pg8000_native.identifier(table)}'"
f"{schema_str} TABLE_NAME = {pg8000_native.literal(table)}"
f");"
)
return len(cursor.fetchall()) > 0
Expand Down

0 comments on commit 45848df

Please sign in to comment.