简体   繁体   English

将数据从 pandas df 插入 sql 时出现“浮点对象没有属性行”错误

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

I have a pandas dataframe that i am trying to append to sql database.我有一个 pandas 数据框,我正在尝试附加到 sql 数据库。 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?如果我使用插入,我的代码会追加或覆盖吗?

我可能遗漏了一些东西,但是您还记得创建行对象吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 属性错误: 'float' object has no attribute 'split' when make word bag from pandas dataframe - Attribute Error: 'float' object has no attribute 'split' when make word bag from pandas dataframe 合并熊猫df时出错。 TypeError :(“类型为“ float”的对象没有len()”,“发生在索引D”) - Error when merging pandas df. TypeError: (“object of type 'float' has no len()”, 'occurred at index D') 将大量数据从 Pandas df 插入到 postgresql 时出现语法错误 - Syntax Error while inserting bulk data from pandas df to postgresql 尝试扩展行数据并转换为 DataFrame,出现此错误:AttributeError: 'float' object has no attribute 'keys' - Trying to expand row data and convert to DataFrame, getting this error: AttributeError: 'float' object has no attribute 'keys' 使用熊猫提供的“ where”方法时,“ AttributeError:&#39;float&#39;对象没有属性&#39;all&#39;” - “AttributeError: 'float' object has no attribute 'all'” when using “where” method from Pandas Pandas: AttributeError: 'float' object 没有属性 'isnull' - Pandas: AttributeError: 'float' object has no attribute 'isnull' Pandas - 浮动对象没有属性 ix - Pandas - float object has no attribute ix AttributeError:“ float”对象在熊猫中没有属性“ split” - AttributeError: 'float' object has no attribute 'split' in pandas 属性错误浮动对象没有属性“追加” - Attribute error float object has no attribute 'append' 熊猫python:np.array_split(df,x)引发错误:&#39;DataFrame&#39;对象没有属性&#39;size&#39; - pandas python: np.array_split(df, x) throws an error: 'DataFrame' object has no attribute 'size'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM