Open rahul-vinaudit opened 3 months ago
This does not work for me
with connection.cursor() as cursor: query = "DO $$ BEGIN BEGIN INSERT INTO testtable2 (test1, test2, test3) VALUES (%s, %s, %s); END; END $$;" parameters = (333, 'STRING $$$ SOME STRING', 'Some string', ) cursor.execute(query, parameters) cursor.execute("COMMIT") connection.close()
But when I remove the $ sign in the string, it is working ?
STRING $$$ SOME STRING
or If I escape the $ it is working as well.
Like this works /root/test_bug2.py:20: SyntaxWarning: invalid escape sequence '\$' parameters = (333, 'STRING \$\$\$ SOME STRING', 'Some string', )
with connection.cursor() as cursor: query = "DO $$ BEGIN BEGIN INSERT INTO testtable2 (test1, test2, test3) VALUES (%s, %s, %s); END; END $$;" parameters = (333, 'STRING \$\$\$ SOME STRING', 'Some string', ) cursor.execute(query, parameters) cursor.execute("COMMIT") connection.close()
Does it work with psycopg 3?
PostgreSQL version: I'm using Yugabytes
I think it's a bug on their side.
This does not work for me
with connection.cursor() as cursor: query = "DO $$ BEGIN BEGIN INSERT INTO testtable2 (test1, test2, test3) VALUES (%s, %s, %s); END; END $$;" parameters = (333, 'STRING $$$ SOME STRING', 'Some string', ) cursor.execute(query, parameters) cursor.execute("COMMIT") connection.close()
But when I remove the $ sign in the string, it is working ?
STRING $$$ SOME STRING
or If I escape the $ it is working as well.
Like this works /root/test_bug2.py:20: SyntaxWarning: invalid escape sequence '\$' parameters = (333, 'STRING \$\$\$ SOME STRING', 'Some string', )
with connection.cursor() as cursor: query = "DO $$ BEGIN BEGIN INSERT INTO testtable2 (test1, test2, test3) VALUES (%s, %s, %s); END; END $$;" parameters = (333, 'STRING \$\$\$ SOME STRING', 'Some string', ) cursor.execute(query, parameters) cursor.execute("COMMIT") connection.close()