'Float object has no attribute row' error when inserting data from pandas df to sql

Viewed 27

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?

1 Answers

I might be missing something, but did you remember to create the row object?

Related