-
|
I could not find any documentation on this. I have a statement with a placeholder: Instead of a datetime object, I would like to submit the sql statement |
Beta Was this translation helpful? Give feedback.
Answered by
dvarrazzo
Nov 16, 2025
Replies: 1 comment 3 replies
-
|
You can the psycopg2.sql objects for it. Untested: sql.SQL("INSERT INTO foo (id, timestamp_updated) VALUES ({id}, {timestamp_updated})") \
.format(id=sql.Literal(my_id), timestamp_updated=sql.SQL("NOW() AT TIME ZONE 'UTC'")))Look for these objects in the docs. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Correct: with execute you can pass only values, not snippets of SQL expression.