'Attribute error: module 'teradatasql' has no attribute 'connect' please solve this error
import teradatasql as tds import pandas as pd
with tds.connect(None,host='',user='',password=' ') 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 cur.fetchall () ]
connect.commit()
Traceback (most recent call last): File "ttt.py", line 4, in with tds.connect(None,host='',user='',paasword='') as connect: AttributeError: module 'teradatasql' has no attribute 'connect'
Solution 1:[1]
The only syntax problem that I found in your program was "cur.fetchall" which instead should be "cursor.fetchall" because your variable is named "cursor".
Here is the corrected program which I ran:
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()
and I got the following successful output:
[1, 'abc']
[2, 'def']
[3, 'ghi']
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tom Nolan |
