import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="password",
database="stocksdatabase"
)
mycursor = mydb.cursor()
import yfinance as yf
ticker = yf.Ticker("MSFT")
hist=ticker.history(period="max")
column_str = """id, Date, Open, High,
Low, Close, Volume, Dividends, Stock Splits"""
insert_str = ("%s, " * 9)[:-2]
final_str = "INSERT INTO historical_price (%s) VALUES (%s)" % (column_str, insert_str)
mycursor.execute(final_str, hist)
mydb.commit()
I get the error "The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()."
How can I approach this?