|
1 | 1 | --- |
2 | | -title: "Step 1: Configure pymssql environment" |
3 | | -description: "Step 1 of this getting started guide involves installing Python, the Microsoft ODBC Driver for SQL Server, and pymssql into your development environment." |
| 2 | +title: Step 1 - Configure pymssql environment |
| 3 | +description: Step 1 of this getting started guide involves installing Python, the Microsoft ODBC Driver for SQL Server, and pymssql into your development environment. |
4 | 4 | author: David-Engel |
5 | 5 | ms.author: v-davidengel |
6 | | -ms.date: "01/19/2017" |
| 6 | +ms.date: 08/22/2023 |
7 | 7 | ms.service: sql |
8 | 8 | ms.subservice: connectivity |
9 | | -ms.topic: conceptual |
| 9 | +ms.topic: how-to |
| 10 | +# CustomerIntent: As a developer, I want to install the pymssql package so that I can connect to SQL with Python code. |
10 | 11 | --- |
| 12 | + |
11 | 13 | # Step 1: Configure development environment for pymssql Python development |
12 | | -You will need to configure your development environment with the prerequisites in order to develop an application using the Python Driver for SQL Server. |
13 | | - |
14 | | -The Python SQL Drivers use the TDS protocol, which is enabled by default in SQL Server and Azure SQL Database. No additional configuration is required. |
15 | | - |
16 | | -## Windows |
17 | | - |
18 | | -1. **Install Python runtime and pip package manager.** |
19 | | -a. Go to [python.org](https://www.python.org/downloads/) |
20 | | -b. Click on the appropriate Windows installer msi link. |
21 | | -c. Once downloaded run the msi to install Python runtime |
22 | | - |
23 | | -2. **Download pymssql module** from [here](https://www.lfd.uci.edu/~gohlke/pythonlibs/#pymssql) |
24 | | - |
25 | | - Make sure you choose the correct `whl` file. For example: If you are using Python 2.7 on a 64-bit machine choose `pymssql‑2.1.1‑cp27‑none‑win_amd64.whl`. Once you download the `whl` file, place it in the C:\Python27 folder. |
26 | | - |
27 | | -3. **Open cmd.exe** |
28 | | - |
29 | | -4. **Install pymssql module.** |
30 | | - For example, if you are using Python 2.7 on a 64-bit machine: |
31 | | -``` |
32 | | -> cd c:\Python27 |
33 | | -> pip install pymssql‑2.1.1‑cp27‑none‑win_amd64.whl |
34 | | -``` |
35 | | - |
36 | | -## Ubuntu Linux |
37 | | - |
38 | | -1. **Install Python runtime and pip package manager.** Python comes pre-installed on most distributions of Ubuntu. If your machine does not have python installed, you can either download the source tarball from [python.org](https://www.python.org/downloads/) and build locally, or you can use the package manager: |
39 | | -``` |
40 | | -> sudo apt-get install python |
41 | | -``` |
42 | | - |
43 | | -2. **Open terminal** |
44 | | - |
45 | | -3. **Install pymssql module and dependencies** |
46 | | -``` |
47 | | -> sudo apt-get --assume-yes update |
48 | | -> sudo apt-get --assume-yes install freetds-dev freetds-bin |
49 | | -> sudo apt-get --assume-yes install python-dev python-pip |
50 | | -> sudo pip install pymssql |
51 | | -``` |
52 | | - |
53 | | -## macOS |
54 | | - |
55 | | -1. **Install Python runtime and pip package manager** |
56 | | -a. Go to [python.org](https://www.python.org/downloads/) |
57 | | -b. Click on the appropriate macOS installer pkg link. |
58 | | -c. Once downloaded run the pkg to install Python runtime |
59 | | - |
60 | | -2. **Open terminal** |
61 | | - |
62 | | -3. **Install Homebrew package manager** |
63 | | -``` |
64 | | -> ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
65 | | -``` |
66 | | - |
67 | | -4. **Install FreeTDS module** |
68 | | -``` |
69 | | -> brew install FreeTDS |
70 | | -``` |
71 | | - |
72 | | -5. **Install pymssql module** |
73 | | -``` |
74 | | -> sudo -H pip install pymssql |
75 | | -``` |
| 14 | + |
| 15 | +You need to configure your development environment with the prerequisites in order to develop an application using the Python Driver for SQL Server. The Python SQL Drivers use the TDS protocol, which is enabled by default in SQL Server and Azure SQL Database. No extra configuration is required. |
| 16 | + |
| 17 | +## Prerequisites |
| 18 | + |
| 19 | +- Python 3 |
| 20 | + - If you don't already have Python, install the **Python runtime** and **Python Package Index (PyPI) package manager** from [python.org](https://www.python.org/downloads/). |
| 21 | + - Prefer to not use your own environment? Open as a devcontainer using [GitHub Codespaces](https://github.com/features/codespaces). |
| 22 | + - [](https://codespaces.new/github/codespaces-blank?quickstart=1). |
| 23 | + |
| 24 | +## Install the pymssql package |
| 25 | + |
| 26 | +Get the [`pymssql` package](https://pypi.org/project/pymssql/) from PyPI. |
| 27 | + |
| 28 | +1. Open a command prompt in an empty directory. |
| 29 | + |
| 30 | +1. Install the [`pymssql` package](https://pypi.org/project/pymssql/). |
| 31 | + |
| 32 | + ```bash |
| 33 | + pip install pymssql |
| 34 | + ``` |
| 35 | + |
| 36 | +## Check installed packages |
| 37 | + |
| 38 | +You can use the PyPI command-line tool to verify that your intended packages are installed. |
| 39 | + |
| 40 | +1. Check the list of installed packages with `pip list`. |
| 41 | + |
| 42 | + ```bash |
| 43 | + pip list |
| 44 | + ``` |
| 45 | + |
| 46 | +## Next steps |
| 47 | + |
| 48 | +> [!div class="nextstepaction"] |
| 49 | +> [Step 2: Create an SQL database for pymssql Python development](step-2-create-a-sql-database-for-pymssql-python-development.md) |
0 commit comments