Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
import io
import datetime
import sqlite3
import pandas as pddf = pd.DataFrame({"x": [1, 2, 3, 4, 5], "y": [5, 4, 3, 2, 1], "z": [1, 1, 1, 1, 1]})
df.head()Loading...
bio = io.BytesIO()
df.to_parquet(bio)
bio.seek(0)0conn = sqlite3.connect("blob.sqlite3")
conn.execute(
"""
CREATE TABLE IF NOT EXISTS queries (
query Text NOT NULL PRIMARY KEY,
timestamp Real NOT NULL,
data Blob NOT NULL
)
"""
)
conn.execute(
"""
insert into queries (
query, timestamp, data
) values (
?, ?, ?
)
""",
["select * from queries", datetime.datetime.now().timestamp(), bio.read()],
)<sqlite3.Cursor at 0x7f8415d66c70>rows = conn.execute("select * from queries").fetchall()bio2 = io.BytesIO(rows[0][2])bio2.seek(0)0pd.read_parquet(bio2)Loading...