I having problem regarding store data in mysql database. a variable having list of list df = [['Euro', 0.877641, '2018-10-24'], ['British Pound', 0.7752180000000001, '2018-10-24'], ['Indian Rupee', 73.21869000000001, '2018-10-24'], ['Australian Dollar', 1.4135360000000001, '2018-10-24'], ['Canadian Dollar', 1.299316, '2018-10-24']]
want to store this in the column currency_name, date ,value from the last updated date. So How could i write that logic in code(my be with max(), min() method of sql.)
tryied:
import pandas as pd
import pymysql
import MySQLdb
sqlconn = pymysql.connect(host='ip', port=port, user='username',
passwd='pass', db='dbname', autocommit=True)
# Create a cursor object
if (sqlconn == None):
print("conn not found")
else:
print("conn is found")
cursor.execute("INSERT INTO TestCurrencyHistory (currency, date, value) VALUES (%s, %s, %s)") % (
elements
)
element = cursor.fetchall()
cursor.close()
sqlconn.close()
Offcource this is not working. So please help ..
thanks in advance..(please let me no if there is any python/pandas logic to choose max and min date)