Hi all
Regarding query and parameter binding in psycopg3:

cur.execute('SELECT * FROM system.app_user WHERE can_edit_views = %s', (True,)) <psycopg.Cursor [TUPLES_OK] [INTRANS] (host=localhost port=5433 user=postgres database=test4) at 0x127b7f0> cur.execute('SELECT * FROM system.app_user WHERE can_edit_views IS %s', (True,))
Traceback (most recent call last):
  Python Shell, prompt 10, line 1
    # Used internally for debug sandbox under external interpreter
File "C:\Python310\Lib\site-packages\psycopg\cursor.py", line 555, in execute
    raise ex.with_traceback(None)
psycopg.errors.SyntaxError: syntax error at or near "$1"
LINE 1: SELECT * FROM system.app_user WHERE can_edit_views IS $1
                                                              ^
Is there any reason why the second query results in a syntax error?
I can use the first form but usually to check a boolean or null value in SQL the IS [true|false|null]/ IS NOT [true|false|null] operator is used.

--
Paolo De Stefani


Reply via email to