23 lines
687 B
Python
23 lines
687 B
Python
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()
|