Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$$$ in string causing issues with execution #1704

Open
rahul-vinaudit opened this issue Jun 7, 2024 · 2 comments
Open

$$$ in string causing issues with execution #1704

rahul-vinaudit opened this issue Jun 7, 2024 · 2 comments

Comments

@rahul-vinaudit
Copy link

rahul-vinaudit commented Jun 7, 2024

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()

  • OS: Centos
  • Psycopg version: 2.9.9 (dt dec pq3 ext lo64)
  • Python version: Python3.12
  • PostgreSQL version: I'm using Yugabytes
@dvarrazzo
Copy link
Member

Does it work with psycopg 3?

@dvarrazzo
Copy link
Member

PostgreSQL version: I'm using Yugabytes

I think it's a bug on their side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants