Saturday, June 2, 2018

How do you connect to SQL Server from Python?

Well, like other software you need a Python SQL Driver. These drivers can be downloaded from here:

https://docs.microsoft.com/en-us/sql/connect/python/python-driver-for-sql-server?view=sql-server-2017

There are two drivers and Microsoft recommends using pyodbc.

pyodbc
pymssql


The one thing that bothers me is that the drivers are Python version dependent and there are so many of them. This is only for Windows that includes both x32bit and x64bit.

Go here to get the proper one:
https://www.python.org/downloads/windows/

I am on Windows 10 Pro Version 1803 (OS Build 17134.48). I also have several versions of SQL Servers. I will try out the web installer for x32 and x64 versions of Python3.7.0b5(64).

No comments: