Bitcoin Price graph plot with Python program + mysql
I hope you have gone through the post which I explained about storing the bitcoin price in mysql database using api. If not please read/watch that.https://steemit.com/dtube/@naveendavisv/pzq0msq2
Below program , we try to connect to mysql database and query the table crypto_table. The fields price_usd,date_time are plotted as X,Y axis using the mathplotlib module function plot.
In the query which we execute can have where clause,groupby etc.
import sys
import matplotlib.pyplot as plt
import pymysql
#connect to mysql database
con = pymysql.connect(host='127.0.0.1',user='usrname',passwd='password',db='mysql')
cursor = con.cursor()
cursor.execute("select date_time,price_usd from crypto_table where id ='bitcoin'");
result = cursor.fetchall()
time = []
price = []
for record in result:
time.append(record[1])
price.append(record[0])
plt.plot(time,price ,'ro')
plt.show()
save the above program and run it from command line.
Database table data:

