Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up
I'm currently switching over from psycopg2 to asyncpg. Many things are solved pretty well/consistent with asyncpg but there is one thing I'm really missing: Named parameters to a query. Here is how I typically make my queries with psycopg2:
This syntax with named parameters makes the code a lot easier to read (and less likely to contain errors).
As of now, asyncpg only supports an
argsarray with a number of parameters, which are referenced as$1,$2, ... in the query. I'm sometimes writing really complex queries with 5-10 joins and dozens of different query parameters (some of them added at runtime depending on user input). It is really easy to mess up some parameter numbers with that. So it would be really great if you could add a way to use named parameters as an alternative to numbers. This could be done with something like$fooinstead of$1in the sql and then passing a dictionary instead of the args list.