Skip to content
Snippets Groups Projects
Commit 73fbf1ee authored by Bastien Abadie's avatar Bastien Abadie
Browse files

Support dict & list through json

parent 97f85431
No related branches found
No related tags found
No related merge requests found
import json
import logging
import sqlite3
import tempfile
......@@ -50,13 +51,19 @@ def save_sqlite(rows, table, cursor):
"""
Write a chunk of rows into an SQLite table
"""
def _serialize(value):
# Serialize UUID as string
if isinstance(value, uuid.UUID):
return str(value)
# Serialize list and dicts as json
if isinstance(value, (list, dict)):
return json.dumps(value)
return value
# Serialize UUID and lists as strings
rows = [
[
str(value) if isinstance(value, (uuid.UUID, list)) else value
for value in row
]
list(map(_serialize, row))
for row in rows
]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment