Thomas Teixeira
unread,Jul 3, 2025, 7:43:35 PMJul 3Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to python...@googlegroups.com
Hi ! Loving apsw so far, thanks !
I'm trying to use `TypesConverterCursorFactory` to auto transform `list`s and `dict`s
as json representation so I can work with them in SQLite using builtin json support.
The issue is that I cannot seem to be able to use the `cursor_factory` and `row_trace`
properties at the same time.
It would seem that when a `cursor_factory`, other than the default `Cursor` value,
is set, the `row_trace` is not called ?
A minimal example to illustrate what I'm saying :)
```py
import dataclasses
import json
import apsw
from apsw.ext import DataClassRowFactory, TypesConverterCursorFactory
conn = apsw.Connection(":memory:")
converter = TypesConverterCursorFactory()
converter.register_adapter(list, lambda _list: json.dumps(_list or []))
converter.register_converter(
"LIST",
lambda _list: json.loads(_list or [])
)
conn.row_trace = DataClassRowFactory(dataclass_kwargs={"frozen": True})
conn.cursor_factory = converter
conn.execute("CREATE TABLE mvt(column1 LIST)")
l = [1, 2, 3, 4]
conn.execute("INSERT INTO mvt VALUES(?)", (l, ))
rows = conn.execute("select * from mvt limit 1")
for row in rows:
# This should print `True` but prints `False`
print(dataclasses.is_dataclass(row))
```