1
0
mirror of https://github.com/Microsoft/sql-server-samples.git synced 2025-12-08 14:58:54 +00:00
Files
sql-server-samples/samples/connect/python/windows/README.md
2016-07-18 16:08:26 -07:00

1.4 KiB
Raw Blame History

Connect to SQL Database by using Python on Windows

[Python code sample] (sample_python_win.py) that runs on a Windows computer. The sample and connects to Azure SQL Database by using the pymssql driver.

Requirements

Install the required modules

Install pymssql.

Make sure you choose the correct whl file.

For example : If you are using Python 2.7 on a 64 bit machine choose : pymssql2.1.1cp27nonewin_amd64.whl. Once you download the .whl file place it in the the C:/Python27 folder.

Now install the pymssql driver using pip from command line. cd into C:/Python27 and run the following

pip install pymssql2.1.1cp27nonewin_amd64.whl

Instructions to enable the use pip can be found here

Create a database and retrieve your connection string

See the getting started page to learn how to create a sample database and get your connection string. It is important you follow the guide to create an AdventureWorks database template. The samples shown below only work with the AdventureWorks schema.