DCAv2/profits/db_read.py

25 lines
689 B
Python

import sqlite3
import time
import json
# Connect to the SQLite database
conn = sqlite3.connect('profits/profits_database.db')
cursor = conn.cursor()
# Execute a SELECT query to retrieve data from the database
cursor.execute('SELECT * FROM profits_table')
# Fetch all rows from the result set
rows = cursor.fetchall()
# Process the fetched rows
#for row in rows:
#human_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(row[0])))
#print(human_time,row[1],round(row[2],2),row[3]) # Or do whatever processing you need
data = json.loads(rows[-3][-1])
print(data[-1])
print(f"Number of entries: {len(rows)}")
# Close the connection
conn.close()