-
Notifications
You must be signed in to change notification settings - Fork 16
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
sqlalchemy.text() used for qmark queries in SQLite #57
Comments
I ran into the same issue. Looks like the problem is known for quite some time #3. According to the language support page of sqlc, SQLite is not supported. Would it be possible to throw an error when using the |
Sure, throwing an error would be better than nothing, but fixing it would be even better of course. I think the fix should be fairly simple, since the generated Python code has a kwarg named after the SQL field def get_user(self, *, id: Any) So the rendering code should have knowledge somehow of this identifier, and can use it to correctly render named placeholders instead of question marks. If someone can point me towards a piece of code where it uses this knowledge to build the function header, I can try to prepare a fix. |
For anyone running into the same issue: I found a workaround. -- name: GetUser :one
SELECT * FROM users
WHERE id = @id and set the engine to |
Hello,
I am using sqlc v1.27.0, sqlc-gen-python 1.2.0 and sqlalchemy 1.4.54.
Example query:
Generated code:
This code does not execute. Running
gives error
This happens because
sqlalchemy.text()
expects bound parameters to usewhere id = :id
style. By using qmark style bound parameters (where id = ?
), this query is not recognized to be a prepared statement and is probably run as-is, and SQLalchemy does not send parameter values with it. Reference: https://docs.sqlalchemy.org/en/14/core/tutorial.html#using-textual-sqlI cannot find a workaround for this. Using
or
yields
which causes the same error. If you want to use
sqlalchemy.text()
, you have to use:parameter
syntax.The text was updated successfully, but these errors were encountered: