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

Document how to use prepared statements #125

Open
hashhar opened this issue Nov 16, 2021 · 1 comment
Open

Document how to use prepared statements #125

hashhar opened this issue Nov 16, 2021 · 1 comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@hashhar
Copy link
Member

hashhar commented Nov 16, 2021

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.

@hashhar hashhar added documentation Improvements or additions to documentation good first issue Good for newcomers labels Nov 16, 2021
@callado4
Copy link

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_...

@damian3031 damian3031 self-assigned this Dec 20, 2022
@damian3031 damian3031 removed their assignment Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Development

No branches or pull requests

3 participants