2024-06-16 11:50:37 发布
网友
我想在UnQLite数据库中存储一个字典,以便以后使用。但是,UnQLite将其存储为字符串:
>>> from unqlite import UnQLite >>> db = UnQLite() >>> db['dict'] = {'a': 5} >>> db['dict'] "{'a': 5}"
我发现我可以使用collection,然后用它们的本机类型检索数据。在
collection
>>> from unqlite import UnQLite >>> db = UnQLite() >>> colors = db.collection('colors') >>> if not colors.exists(): ... colors.create() ... >>> colors.store([{'name': 'red', 'code': '#ff0000'}, {'name': 'green', 'code': '#00ff00'}]) 1 >>> colors.all() [{'code': '#ff0000', 'name': 'red', '__id': 0}, {'code': '#00ff00', 'name': 'green', '__id': 1}]
我发现我可以使用
collection
,然后用它们的本机类型检索数据。在相关问题 更多 >
编程相关推荐