“type'NoneType'is not iterable”error when called pymssql.connect

“type'NoneType'is not iterable”error when called pymssql.connect

问题描述:

我在我的电脑上安装了SQL Server,在同一台计算机上我尝试使用python连接数据库,但出现以下错误:“type'NoneType'is not iterable”error when called pymssql.connect

>>> from os import getenv 
>>> import pymssql 
>>> server = getenv(“КОМП”) 
>>> user = getenv(“user”) 
>>> password = getenv(“”) 
>>> conn = pymssql.connect(server, user, password, “Test”) 
    Traceback (most recent call last): 
    File “<pyshell#6>”, line 1, in <module> 
    conn = pymssql.connect(server, user, password, “Test”) 
    File “pymssql.pyx”, line 635, in pymssql.connect (pymssql.c:10734) 
    File “_mssql.pyx”, line 1902, in _mssql.connect (_mssql.c:21821) 
    File “_mssql.pyx”, line 552, in _mssql.MSSQLConnection.__init__ (_mssql.c:5891) 
    TypeError: argument of type ‘NoneType’ is not iterable 

朋友请帮忙。我想我写的不正确的服务器,用户的名字......我的输入窗口的屏幕截图附加到SQL Server数据库的登录数据

login data

server = getenv("КОМП") 

正在恢复None ,并且pymssql.connect在尝试解析None作为服务器名称时会窒息。从你的截图看起来你应该简单地使用

server = "КОМП"