feat: read from db and plot difficulty factor vs time

This commit is contained in:
Aravinth Manivannan 2023-08-03 14:54:53 +05:30
parent 2f4c6b867f
commit 5445ec8a21
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
2 changed files with 36 additions and 0 deletions

23
plot.py Normal file
View file

@ -0,0 +1,23 @@
import psycopg2
import matplotlib.pyplot as plt
from mplcursors import cursor # separate package must be installed
# Connect to your postgres DB
conn = psycopg2.connect("postgres://postgres:password@localhost:5420/postgres")
# Open a cursor to perform database operations
cur = conn.cursor()
# Execute a query
cur.execute("SELECT difficulty FROM logs ORDER BY difficulty")# LIMIT 100000")
# Retrieve query results
difficulty = cur.fetchall()
cur.execute("SELECT time FROM logs ORDER BY difficulty")# LIMIT 100000")
time = cur.fetchall()
# reproducible sample data as a pandas dataframe
#plt.figure(figsize=(4096, 4096))
plt.scatter(difficulty, time)
#cursor(hover=True)
plt.show()

13
requirements.txt Normal file
View file

@ -0,0 +1,13 @@
contourpy==1.1.0
cycler==0.11.0
fonttools==4.42.0
kiwisolver==1.4.4
matplotlib==3.7.2
mplcursors==0.5.2
numpy==1.25.2
packaging==23.1
Pillow==10.0.0
psycopg2==2.9.6
pyparsing==3.0.9
python-dateutil==2.8.2
six==1.16.0