[英]SQLCODE=-30081 Cannot connect to IBM DB2 database with python
I am able to connect to DB2 just fine with my TOAD application however I need to be able to connect within python to build some automated reports.我可以用我的 TOAD 应用程序很好地连接到 DB2,但是我需要能够在 python 中连接以构建一些自动报告。
I have installed the ibm_db
library and I am trying to follow the instructions but I keep getting error SQLCODE=-30081
.我已经安装了
ibm_db
库,我正在尝试按照说明进行操作,但我不断收到错误SQLCODE=-30081
。
import ibm_db
conn_str = 'database=XXXX;hostname=XXXX.host.com;port=11111;protocol=tcpip;uid=user;pwd=password'
conn = ibm_db_conn = ibm_db.connect(conn_str,'','')
Traceback:追溯:
Traceback (most recent call last):
File "C:/Users/username/PycharmProjects/Report/MAIN/MAIN.py", line 4, in <module>
conn = ibm_db_conn = ibm_db.connect(conn_str,'','')
SQLCODE=-30081
Looking up -30081
is not very helpful as it can be caused by a list of things.查找
-30081
不是很有帮助,因为它可能是由一系列事物引起的。
I did read somewhere that maybe ibm_db
is only supported on Python 3.4 and I am using Python 3.6 however I cannot install Python 3.4 on my work PC right now as its admin locked.我确实在某处读到过,也许
ibm_db
仅在 Python 3.4 上受支持,并且我使用的是 Python 3.6,但是我现在无法在我的工作 PC 上安装 Python 3.4,因为它的管理员已锁定。
Update:更新:
Tested connection using the command line with the 2 different connections options available to ibm_db.使用命令行和 ibm_db 可用的 2 个不同连接选项测试连接。
Both connections types:两种连接类型:
import ibm_db
conn_str = 'database=XXXX;hostname=111.111.111.111;port=11111;protocol=tcpip;uid=username;pwd=password'
try:
conn = ibm_db.connect(conn_str, '', '')
except:
print("no connection:", ibm_db.conn_errormsg())
else:
print("The 1st connection was successful")
try:
conn = ibm_db.connect('XXXX', 'username', 'password')
except:
print("no connection:", ibm_db.conn_errormsg())
else:
print("The 2nd connection was successful")
Error:错误:
C:\Users\username\Desktop\Python 3.6.2>python test.py
no connection: [IBM][CLI Driver] SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected: "111.111.111.111". Communica SQLCODE=-30081etecting the error: "recv". Protocol specific error code(s): "10054", "*", "0". SQLSTATE=08001
no connection: [IBM][CLI Driver] SQL30082N Security processing failed with reason "19" ("USERID DISABLED or RESTRICTED" SQLCODE=-30082001
Any guidance would be appreciated.任何指导将不胜感激。
Your error message says:您的错误消息说:
SQL30082N Security processing failed with reason "19" ("USERID DISABLED or RESTRICTED" SQLCODE=-30082001 SQL30082N 安全处理失败,原因为“19”(“USERID DISABLED or RESTRICTED” SQLCODE=-30082001
Here is one of good articles for this message:这是此消息的一篇好文章:
Error SQL30082N Reason Code 19 or 24
错误 SQL30082N 原因代码 19 或 24
https://www.ibm.com/support/pages/error-sql30082n-reason-code-19-or-24 https://www.ibm.com/support/pages/error-sql30082n-reason-code-19-or-24
Here is snipped, we may need to follow on Windows:这里被剪断了,我们可能需要在 Windows 上遵循:
4.) If you are on Windows please make sure that the group the user is apart of is added to: "Access this computer from network".
4.) 如果您使用的是 Windows,请确保将用户所在的组添加到:“从网络访问此计算机”。 To check this please do the following:
要检查这一点,请执行以下操作:
Click on Start->Run from the Windows start menu Type "secpol.msc" Go to Local Policies->User Rights Assignments.
从 Windows 开始菜单中单击开始 -> 运行 键入“secpol.msc” 转到本地策略 -> 用户权限分配。 Double-click on "Access this computer from network"
双击“从网络访问这台计算机”
For more information on this topic please see the "Related URL" for more information有关此主题的更多信息,请参阅“相关 URL”以获取更多信息
Hope this helps.希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.