首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >属性错误:模块'teradatasql‘没有属性“连接”,请解决此错误

属性错误:模块'teradatasql‘没有属性“连接”,请解决此错误
EN

Stack Overflow用户
提问于 2022-05-10 05:10:18
回答 2查看 199关注 0票数 -1

进口特拉达塔斯库为tds进口熊猫为pd

以tds.connect(None,host='',user='',password=‘')作为连接: cursor=connect.cursor () cursor.execute (“在提交保存行上创建易失性表voltab (c1整型,c2 varchar(100))”)

代码语言:javascript
复制
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‘

EN

回答 2

Stack Overflow用户

发布于 2022-05-12 21:03:45

我在您的程序中发现的唯一语法问题是"cur.fetchall“,它应该是"cursor.fetchall”,因为您的变量名为“cursor.fetchall”。

下面是我运行的修正程序:

代码语言:javascript
复制
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()

我得到了以下成功的输出:

代码语言:javascript
复制
[1, 'abc']
[2, 'def']
[3, 'ghi']
票数 0
EN

Stack Overflow用户

发布于 2022-07-12 15:14:15

解决方案不是将Python文件命名为与在该Python文件中导入的任何模块相同的名称。

我读到:https://geektechstuff.com/2020/06/13/attributeerror-partially-initialized-module-has-no-attribute-python/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72181000

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档