databases icon indicating copy to clipboard operation
databases copied to clipboard

Common interface for each backends Record/RowProxy

Open skewty opened this issue 5 years ago • 0 comments

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.

skewty avatar Jun 02 '20 16:06 skewty