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/pymssql/mac
2016-07-25 00:48:25 -07:00
..
2016-07-25 00:48:25 -07:00
2016-07-25 00:48:25 -07:00

Connect to SQL Database by using Python on Mac OS

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

Requirements

Install the required modules

Open your terminal and install

1) Homebrew: Run the following command from your terminal. This will download the Homebrew package manager on your machine.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2) FreeTDS: Run the following command from your terminal. This will download FreeTDS on your machine. FreeTDS is required for pymmsql to work.

brew install FreeTDS

3) Pymmsql: Run the following command from your terminal. This will install pymmsql on your machine.

sudo -H pip install pymssql

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.