I have a pandas dataframe that i am trying to append to sql database. I tried
import pyodbc
conn = pyodbc.connect('dsn=azure_warehouse_dev;'
'Trusted_Connection=yes;')
cursor = conn.cursor()
cursor.execute("INSERT INTO dim.h2oquoterscores(SalesForceSubscriberKey,predict,p0,p1,Model,date) VALUES (?,?,?,?,?,?)",(row.SalesForceSubscriberKey,row.predict,row.p0,row.p1.row.Model,row.date))
But i receive the error
Traceback (most recent call last):
File "C:\Users\jj\AppData\Local\Temp\ipykernel_20004\2924215405.py", line 1, in <cell line: 1>
cursor.execute("INSERT INTO dim.h2oquoterscores(SalesForceSubscriberKey,predict,p0,p1,Model,date) VALUES (?,?,?,?,?,?)",(row.SalesForceSubscriberKey,row.predict,row.p0,row.p1.row.Model,row.date))
AttributeError: 'float' object has no attribute 'row'
Also,I am trying to write this to the table daily. will my code append or overwrite if i use insert?
我可能遗漏了一些东西,但是您还记得创建行对象吗?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.