try:
with conn.cursor() as cursor:
for i in range(0,len(Portfolio)):
sql = 'Select Price_Div.Ticker, Price_Div.Date, Price_Div.Price_Div from Price_Div where Price_Div.Date = STR_TO_DATE(%s,\'%%Y%%m%%d\') and Price_Div.Ticker = \'' + Portfolio[i] + '\''
cursor.execute(sql,str(Date.year)+str(Date.strftime('%m'))+str(Date.strftime('%d')))
rowsa = cursor.fetchall()
rows = rows + rowsa
conn.commit()
finally:
conn.close()
I ran the following code, but it seems to be taking a lot of time. Is there any way to save time?
pymysql
...
where
...
and Price_Div.Ticker = \'' + Portfolio[i] + '\''
Try using in
instead of =
.
© 2024 OneMinuteCode. All rights reserved.