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

Common interface for each backends Record/RowProxy #214

Open
skewty opened this issue Jun 2, 2020 · 0 comments
Open

Common interface for each backends Record/RowProxy #214

skewty opened this issue Jun 2, 2020 · 0 comments

Comments

@skewty
Copy link

@skewty skewty commented Jun 2, 2020

Current implementation has different class for each Row/Record/RowProxy.

Any chance a common interface can be used / monkey patched into each of these so they behave more similarly.

Something as simple as:

from typing import Mapping
row = await database.fetch_one(query)
isinstance(row, Mapping)
# returns True for Postgres but False for SQLite

Also the __str__ and __repr__ have a vastly different look.
The postgres Record class has neither a __str__ nor a __repr__ (PR for __str__ done that returns what looks like a standard python dict / Mapping)

But when you get a RowProxy from sqlite it looks like a tuple. This is surprising because RowProxy has item(), keys(), values(). Shouldn't it look more like a mapping in __str__?

I haven't investigated mysql yet.

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

Successfully merging a pull request may close this issue.

None yet
1 participant