plot mariadb datas
parent
d8e46f556b
commit
af6c1c4a02
@ -1,16 +1,45 @@
|
|||||||
import sqlite3, pandas, matplotlib
|
|
||||||
matplotlib.use('tkAgg')
|
|
||||||
import matplotlib.pyplot as plt
|
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()
|
||||||
|
|
||||||
conn = sqlite3.connect("bandwidth.db")
|
# 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()
|
||||||
|
|
||||||
sql = """SELECT times, ping, download, upload FROM bandwidth"""
|
times = []
|
||||||
|
pings = []
|
||||||
|
downloads = []
|
||||||
|
uploads = []
|
||||||
|
|
||||||
data = pandas.read_sql(sql, conn)
|
for i in mariadbResult:
|
||||||
|
times.append(i[0])
|
||||||
|
pings.append(i[1])
|
||||||
|
downloads.append(i[2])
|
||||||
|
uploads.append(i[3])
|
||||||
|
|
||||||
plt.plot(data.times,data.ping, label = "Ping", )
|
# plot
|
||||||
plt.plot(data.times,data.download, label = "Download")
|
plt.plot(times, pings, label="Ping")
|
||||||
plt.plot(data.times,data.upload, label = "Upload")
|
plt.plot(times, downloads, label="Download")
|
||||||
|
plt.plot(times, uploads, label="Upload")
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.title("Bandwidth")
|
plt.title("bandwidth from mariadb")
|
||||||
plt.show()
|
plt.show()
|
||||||
Loading…
Reference in New Issue