[issue35889] sqlite3.Row doesn't have useful repr
Erlend Egeberg Aasland
report at bugs.python.org
Thu Apr 8 04:55:02 EDT 2021
Erlend Egeberg Aasland <erlend.aasland at innova.no> added the comment:
AFAICS, this is fixed by the attached one-liner, based on Serhiy's suggestion (based on Raymond's suggestion).
$ python3.10 test.py
<sqlite3.Row object at 0x102b91330>
$ ./python.exe test.py # patch applied
<sqlite3.Row object at 0x10c06b600 {'number': 1, 'string': 'two', 'blob': b'\x1f'}>
$ cat test.py
import sqlite3
cx = sqlite3.connect(":memory:")
cx.row_factory = sqlite3.Row
query = """
select
1 as number,
'two' as string,
x'1f' as blob
"""
for row in cx.execute(query):
print(repr(row))
If Berker & Serhiy approves, I'll create a PR for it.
----------
nosy: +erlendaasland
Added file: https://bugs.python.org/file49941/patch.diff
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35889>
_______________________________________
More information about the Python-bugs-list
mailing list