Closed nullcount closed 1 year ago
Here is an example of how you can store a dictionary in an SQLite database using Python:
import sqlite3
# Create a connection to the SQLite database
conn = sqlite3.connect('database.db')
# Create a table to store the dictionary
conn.execute("CREATE TABLE dictionary (key text, value text)")
# Define the dictionary
my_dict = {
'apple': 'red',
'banana': 'yellow',
'orange': 'orange'
}
# Insert the key-value pairs into the table
conn.executemany("INSERT INTO dictionary VALUES (?, ?)", my_dict.items())
# Save the changes to the database
conn.commit()
# Close the connection to the database
conn.close()
to get the data back
# Use a SELECT statement to retrieve the key-value pairs from the table
cursor = conn.execute("SELECT * FROM dictionary")
# Retrieve the rows from the table
rows = cursor.fetchall()
# Convert the rows into a dictionary
my_dict = dict(rows)
makes the most sense for htlcstreamer also useful for .history.pkl