【问题标题】:"type 'NoneType' is not iterable" error when calling pymssql.connect调用 pymssql.connect 时出现“类型‘NoneType’不可迭代”错误
【发布时间】:2017-10-21 17:56:19
【问题描述】:

我的计算机上安装了 SQL Server,在同一台计算机上我尝试使用 python 连接到数据库,但出现以下错误:

>>> 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 数据库

【问题讨论】:

    标签: python sql-server sql-server-2014 pymssql


    【解决方案1】:
    server = getenv("КОМП")
    

    正在返回None,而pymssql.connect 在尝试将None 解析为服务器名称时令人窒息。从您的屏幕截图看起来您应该只是使用

    server = "КОМП"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-26
      • 2020-12-14
      • 1970-01-01
      • 2011-12-10
      • 2021-01-23
      • 2011-12-13
      • 2016-09-11
      • 1970-01-01
      相关资源
      最近更新 更多