0

我正在使用 Python 库 pymssql 连接到数据库。我以前从未使用过它,所以错误可能看起来微不足道。

from os import getenv
import pymssql

server = getenv("192.xxx.xxx.xx") 
user = getenv("john.constantine")
password = getenv("xxxxxxx")

conn = pymssql.connect(server, user, password, "tempdb")
cursor = conn.cursor()

cursor.execute('SELECT * from table')
rows = cursor.fetchall()
for row in rows:
    print row

conn.close()

我收到以下错误:

Traceback (most recent call last):
  File "C:\Users\Documents\Demo_DB.py", line 8, in <module>
    conn = pymssql.connect(server, user, password, "tempdb")
  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
[Finished in 0.2s with exit code 1]

我使用这些凭据连接到数据库。 在此处输入图像描述

4

0 回答 0