46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
import matplotlib.pyplot as plt
|
|
import sqlite3
|
|
import pandas
|
|
import matplotlib
|
|
import mysql.connector
|
|
matplotlib.use('tkAgg')
|
|
|
|
# # sqlite3
|
|
# sqlite3Connection = sqlite3.connect("bandwidth.db")
|
|
# sqlQuery = """SELECT times, ping, download, upload FROM bandwidth"""
|
|
# sqlite3Data = pandas.read_sql(sqlQuery, sqlite3Connection)
|
|
|
|
# # plot
|
|
# plt.plot(sqlite3Data.times, sqlite3Data.ping, label="Ping")
|
|
# plt.plot(sqlite3Data.times, sqlite3Data.download, label="Download")
|
|
# plt.plot(sqlite3Data.times, sqlite3Data.upload, label="Upload")
|
|
# plt.legend()
|
|
# plt.title("Bandwidth from sqlite3")
|
|
# plt.show()
|
|
|
|
# mariadb
|
|
mariadbConnection = mysql.connector.connect(
|
|
host="server0", user="root", password="lungretter1", database="bandwidth")
|
|
mariadbCursor = mariadbConnection.cursor()
|
|
mariadbCursor.execute("SELECT times, ping, download, upload FROM speedtest")
|
|
mariadbResult = mariadbCursor.fetchall()
|
|
|
|
times = []
|
|
pings = []
|
|
downloads = []
|
|
uploads = []
|
|
|
|
for i in mariadbResult:
|
|
times.append(i[0])
|
|
pings.append(i[1])
|
|
downloads.append(i[2])
|
|
uploads.append(i[3])
|
|
|
|
# plot
|
|
plt.plot(times, pings, label="Ping")
|
|
plt.plot(times, downloads, label="Download")
|
|
plt.plot(times, uploads, label="Upload")
|
|
plt.legend()
|
|
plt.title("bandwidth from mariadb")
|
|
plt.show()
|