Skip to content

Commit

Permalink
use sa.text()
Browse files Browse the repository at this point in the history
  • Loading branch information
mfshao committed Oct 28, 2022
1 parent fa545f9 commit dc2fa7d
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@


def escape(str):
# escape % and single quotes for SQL statement
return str.replace("%", "%%").replace("'", "''")
# escape colon for sa.text() and single quotes for SQL statement
return str.replace(":", "\:").replace("'", "''")


def upgrade():
Expand All @@ -47,7 +47,7 @@ def upgrade():
sql_statement = f"""UPDATE metadata
SET data='{escape(json.dumps(data))}'
WHERE guid='{guid}'"""
connection.execute(sql_statement)
connection.execute(sa.text(sql_statement))
# Grab another batch of rows
offset += limit
query = f"SELECT guid, data FROM metadata ORDER BY guid LIMIT {limit} OFFSET {offset} "
Expand Down

0 comments on commit dc2fa7d

Please sign in to comment.