trino-python-client
trino-python-client copied to clipboard
Document how to use prepared statements
The client is based on Python DB-API so the usage is cursor.execute(sql, params)
.
We use ?
for params.
So an example would look like:
cursor.execute("SELECT * FROM tbl WHERE col_1 = ? AND col_2 = ?", ("value_1", "value_2",))
Note that params
can either be a tuple or list.
I figured this out on my own but I got an error of trino.exceptions.FailedToObtainAddedPrepareHeader
After a bit of debugging it seems maybe because my server is an older version which return presto in the header. What I mean is that the current version of the library is looking for HEADER_ADDED_PREPARE = 'X-Trino-Added-Prepare'
but the response from the server I'm using has 'X-Presto-Added-Prepare': 'st_...