pudo / dataset

Easy-to-use data handling for SQL data stores with support for implicit table creation, bulk loading, and transactions.
https://dataset.readthedocs.org/
MIT License
4.76k stars 297 forks source link

fix: Handle list type as JSON. #392

Open feanil opened 2 years ago

feanil commented 2 years ago

Before this change, if you had a list of data, it would be inferred as text type. Then when we try to insert data, we would get the following error:

sqlite3.InterfaceError: Error binding parameter 4 - probably unsupported type.

Handling lists as JSON type resolves this error.

abulte commented 1 year ago

@pudo any thoughts on this? I bump into this pretty much every time I use your beloved library (thanks!).

abulte commented 1 year ago

NB: to those looking for a workaround, this is what I currently do:

table.insert({"a": [{'begin': '20230321T151700', 'end': '20230321T161800'}]}, types={"a": db.types.json})

It forces the a column to be recognised as json.