I am using Python library pymssql to connect to a database. I have never used it before so the error might look trivial.
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()
I get the following error:
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]

tempdbis calledtable?server = getenv("192.xxx.xx.xx")is going to setservertoNone, unless you actually have an environment variable named192.xxx.xx.xx. That's probably what's given you the None which is throwing the exception. (Same for your othergetenv.)192.111.111.11, why on earth are you callinggetenv()? Just doserver = '192.111.111.11'and be done with it.