Skip to content

Is it possible to execute select query with named parameters ? #64

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

Closed
vladyslav2 opened this issue Jan 8, 2017 · 2 comments
Closed

Comments

@vladyslav2
Copy link

Lets say i want to do:

SELECT company FROM company WHERE approved = ${approved}

instead of
SELECT company FROM company WHERE approved = $1

thanks in advance

@vladyslav2 vladyslav2 changed the title Is it possible to pass select query with named parameters ? Is it possible to execute select query with named parameters ? Jan 8, 2017
@elprans
Copy link
Member

elprans commented Feb 2, 2017

asyncpg uses native PostgreSQL syntax for parameters, unlike other database drivers, it does not do any sort of parameter interpolation. Hence only the $n syntax is supported.

A possible future enhancement to enable handling of named parameters is tracked in #9.

@bitmodeler
Copy link

To other people hitting this popular posted query; see:

https://gitlab.com/osfda/asyncpg_utility

A python class extension that supports named parameters in prepared statements.

(testing it today; should be stable by next week...)

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

No branches or pull requests

3 participants