Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

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 pd
df = 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)
0
conn = 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)
0
pd.read_parquet(bio2)
Loading...