C
C
cgn2017-10-22 09:06:59
Python
cgn, 2017-10-22 09:06:59

Why can't connect to MS SQL database via python?

Hello. I have MS SQL Server installed on my computer, on the same computer I try to connect to the database using python, but the following error pops up:

>>> from os import getenv
>>> import pymssql
>>> server = getenv("КОМП\MSSQLSERVER")
>>> user = getenv("user")
>>> password = getenv("")
>>> conn = pymssql.connect(server, user, password, "Test")
Traceback (most recent call last):
  File "<pyshell#5>", 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

Please tell me where I made a mistake. I guess I spelled the name of the server, the user ... everything)) Below is a screenshot with the data for logging into the SQL server
59ec348a95c5a380623793.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Skorzhinsky, 2017-10-23
@AndyKorg

Of course, I’m not a fake welder (I don’t know this Python library), but I strongly suspect that instead
of server = getenv("COMP \ MSSQLSERVER"),
you need to write
server = getenv("COMP")
But in users, on the contrary, add the name COMP.
Well, Russian letters in the server name cut the look

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question