def workingSpace(cnx): sql = ("select * from newyorkexchange.ibm_historicalquotes_newyork") df = connectMysqlDB.query(cnx).pandasQuery(sql) #print(df.head(100)) #df['AdjClose'].hist() #p.show() return df
def collectData(): host='149.171.37.73' userName='******' password='******' database='sydneyexchange' cnx = mysql.connector.connect(); try: #get cnx used for connecting DB cnx = connectMysqlDB.cnxStock(host=host,userName=userName,password=password,database=database).connect() # collecting IBM historical data sql = ('select Date , AdjClose, (Volume * AdjClose / Close) AdjVolume from newyorkexchange.aapl_historicalquotes_newyork where Date > \'2010-1-1\'') df = connectMysqlDB.query(cnx).pandasQuery(sql) finally: cnx.close() return df
# import mysql.connector import connectMysqlDB # from mysql.connector import cursor # import pandas as pd # import pandas.io.sql as psql import pylab as p host='149.171.37.73' userName='******' password='******' database='sydneyexchange' cnx = connectMysqlDB.cnxStock(host=host,userName=userName,password=password,database=database).connect() sql = ("SELECT * from aac_historicalquotes_sydney") df = connectMysqlDB.query(cnx).pandasQuery(sql) print(df.head(100)) df['Open'].hist() p.show() train_data = df.head(100) test_data = df.head(); cnx.close() #cnx = mysql.connector.connect(user='******', password='******', host='149.171.37.73', database='sydneyexchange') # cursor = cnx.cursor() # query = ("SELECT * from aac_historicalquotes_sydney") # df = psql.read_sql(query, cnx)