I'm unable to connect to SQL Server from Python (3.4.4 64 bit) on Windows 10. This is what I did:
- I found this nice library.
- Then, I followed this page and installed FreeTDS
- After that I installed pymssql with this command:
easy_install pymssql
- In SQL Server Network Configuration I enabled Named Pipes and TCP/IP for my SQLEXPRESS instance
So, at this moment I can run SQL Server and connect to my database, using SQL Server Management Studio. When I log in, I use DESKTOP-1JA5E9F\SQLEXPRESS
as Server Name, sa
as Login and 123
as Password. Besides, in Python shell I can import pymssql
like:
>>> import pymssql
It does not raise any error. However, I can not connect to my database instance. I tried dozens attempts like:
conn = pymssql.connect(host=r'DESKTOP-1JA5E9F\SQLEXPRESS',
user=r'sa', password=r'123', database=r'reestr')
The code above ^^^ never completes (I see just blinking _
in the shell, that is blinking for ever). I also tried this:
conn = pymssql.connect(host=r'SQLEXPRESS', user=r'sa', password=r'123', database=r'reestr')
This results in pymssql.InterfaceError: Connection to the database failed for an unknown reason.
. I tried this:
conn=pymssql.connect(host=r'SQLEXPRESS:1433',user=r'sa',password=r'123', database=r'reestr')
It also results in the same error message. So, I if anybody knows those magic voodoo spells that can do the trick, you are welcome.