pyodbc cursor.execute(查询)在数据库中添加我的用户名
在Jupyter Notebook中,我能够使用'dsn使用PyoBDC连接到工作数据库;用户身份; PW'连接字符串成功。我测试了打印数据库中的所有表名称。然后,我尝试运行以下代码来测试简单的查询。
================================================
query = "select * from TEST_TABLE"
cursor.execute(query)
==============
但是我有以下错误。
ProgrammingError: ('42S02', '[42S02] [IBM][CLI Driver][DB2/AIX64] SQL0204N "**myusername.TEST_TABLE**" is an **undefined name**. SQLSTATE=42704\r\n (-204) (SQLExecDirectW)')
我连接到的数据库中确实存在Test_table。但是由于某种原因,该代码在test_table
的前面添加myusername
,并告诉我未定义表名。
In Jupyter Notebook, I was able to connect to my work database using pyobdc with 'dsn; userid; pw' connection string successfully. I tested out printing all the table names in the database. Then I tried to run the following code to test a simple query.
================================
query = "select * from TEST_TABLE"
cursor.execute(query)
================================
But I got the following error.
ProgrammingError: ('42S02', '[42S02] [IBM][CLI Driver][DB2/AIX64] SQL0204N "**myusername.TEST_TABLE**" is an **undefined name**. SQLSTATE=42704\r\n (-204) (SQLExecDirectW)')
TEST_TABLE does exist in the database I'm connected to. But for some reason, the code is adding myusername
in front of the TEST_TABLE
and tells me the table name is not defined.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试设置PYODBC连接如下:
其中:
Try setting up the PyODBC connection as follows:
where: