-
Notifications
You must be signed in to change notification settings - Fork 417
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
Add ability to set the Record factory on the connection #40
Comments
@elprans nice. Incorporating this issue is invaluable. |
This is necessary not only for dot accessor wanted in #38 and #13. I don't know any way to elegantly convert json, uuid objects from postgres to python objects except thru monkey patching. What I am doing now is ugly IMO. [
{
**record,
'task_id': str(record['task_id']), # uuid to str
'rates': json.loads(t['rates']), # jsonb to dict
}
for record in fetched_records
] The ability to use customized Record is a must, dude. It's been more than 2 years |
Dear "dude", you're welcome to make a PR. Please make sure that the performance of asyncpg code that uses the builtin |
Add the new `record_class` parameter to the `create_pool()` and `connect()` functions, as well as to the `cursor()`, `prepare()`, `fetch()` and `fetchrow()` connection methods. This not only allows adding custom functionality to the returned objects, but also assists with typing (see #577 for discussion). Fixes: #40.
Add the new `record_class` parameter to the `create_pool()` and `connect()` functions, as well as to the `cursor()`, `prepare()`, `fetch()` and `fetchrow()` connection methods. This not only allows adding custom functionality to the returned objects, but also assists with typing (see #577 for discussion). Fixes: #40.
Add the new `record_class` parameter to the `create_pool()` and `connect()` functions, as well as to the `cursor()`, `prepare()`, `fetch()` and `fetchrow()` connection methods. This not only allows adding custom functionality to the returned objects, but also assists with typing (see #577 for discussion). Fixes: #40.
Add the new `record_class` parameter to the `create_pool()` and `connect()` functions, as well as to the `cursor()`, `prepare()`, `fetch()` and `fetchrow()` connection methods. This not only allows adding custom functionality to the returned objects, but also assists with typing (see #577 for discussion). Fixes: #40.
Add the new `record_class` parameter to the `create_pool()` and `connect()` functions, as well as to the `cursor()`, `prepare()`, `fetch()` and `fetchrow()` connection methods. This not only allows adding custom functionality to the returned objects, but also assists with typing (see #577 for discussion). Fixes: #40.
Add the new `record_class` parameter to the `create_pool()` and `connect()` functions, as well as to the `cursor()`, `prepare()`, `fetch()` and `fetchrow()` connection methods. This not only allows adding custom functionality to the returned objects, but also assists with typing (see #577 for discussion). Fixes: #40.
Hey, I have a similar issue the guy above (the "dude"), so I wonder what the solution to it would be using Thanks! |
You need to subclass
and then
You can also specify a record_class per-query. |
Okay I see. I thought I could easily add typing to it too, but that doesn't seem to be the case. (I'm using a connection pool btw) |
You can actually add typing, though we need to land #577 to actually enable type checking. |
In order to provide for alternative ways of accessing fields, or adding custom functionality, make it possible to specify a Record factory on a connection.
See #38 and #13 for related discussions.
The text was updated successfully, but these errors were encountered: