进口特拉达塔斯库为tds进口熊猫为pd
以tds.connect(None,host='',user='',password=‘')作为连接: cursor=connect.cursor () cursor.execute (“在提交保存行上创建易失性表voltab (c1整型,c2 varchar(100))”)
cursor.execute ("insert into voltab (?, ?)", [
[1, "abc"],
[2, "def"],
[3, "ghi"]])
cursor.execute ("select * from voltab order by 1")
[ print (row) for row in cur.fetchall () ]
connect.commit()追溯(最近一次调用):文件"ttt.py",第4行,其中tds.connect(无,host=‘,user='',paasword='')作为连接: AttributeError: AttributeError:模块'teradatasql’没有属性'connect‘
发布于 2022-05-12 21:03:45
我在您的程序中发现的唯一语法问题是"cur.fetchall“,它应该是"cursor.fetchall”,因为您的变量名为“cursor.fetchall”。
下面是我运行的修正程序:
import teradatasql as tds
import pandas as pd
with tds.connect(None, host="whomooz", user="guest", password="please") as connect:
cursor=connect.cursor ()
cursor.execute ("create volatile table voltab (c1 integer, c2 varchar(100)) on commit preserve rows")
cursor.execute ("insert into voltab (?, ?)", [
[1, "abc"],
[2, "def"],
[3, "ghi"]])
cursor.execute ("select * from voltab order by 1")
[ print (row) for row in cursor.fetchall () ]
connect.commit()我得到了以下成功的输出:
[1, 'abc']
[2, 'def']
[3, 'ghi']发布于 2022-07-12 15:14:15
解决方案不是将Python文件命名为与在该Python文件中导入的任何模块相同的名称。
https://stackoverflow.com/questions/72181000
复制相似问题