Skip to content

Commit 6134333

Browse files
committed
Updated pymssql guide
1 parent 3c7b62e commit 6134333

4 files changed

Lines changed: 244 additions & 144 deletions

docs/connect/python/pymssql/python-sql-driver-pymssql.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ ms.service: sql
88
ms.subservice: connectivity
99
ms.topic: conceptual
1010
---
11+
1112
# Python SQL Driver - pymssql
1213

1314
[!INCLUDE[Driver_Python_Download](../../../includes/driver_python_download.md)]
Lines changed: 42 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,49 @@
11
---
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.
44
author: David-Engel
55
ms.author: v-davidengel
6-
ms.date: "01/19/2017"
6+
ms.date: 08/22/2023
77
ms.service: sql
88
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.
1011
---
12+
1113
# 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+
- [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](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)
Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,45 @@
11
---
2-
title: "Step 2: Create a SQL database for pymssql"
3-
description: "Step 2 of this getting started guide involves creating a database in SQL Server or Azure SQL Database for this pymssql sample."
2+
title: Step 2 - Create an SQL database for pymssql
3+
description: Step 2 of this getting started guide involves creating a database in SQL Server or Azure SQL Database for this pymssql sample.
44
author: David-Engel
55
ms.author: v-davidengel
6-
ms.date: "01/19/2017"
6+
ms.date: 08/22/2023
77
ms.service: sql
88
ms.subservice: connectivity
9-
ms.topic: conceptual
9+
ms.topic: how-to
10+
# CustomerIntent: As a developer, I want to create a SQL database so that I can connect to it with Python code.
1011
---
11-
# Step 2: Create a SQL database for pymssql Python development
12-
[!INCLUDE[Driver_Python_Download](../../../includes/driver_python_download.md)]
1312

14-
[!INCLUDE[CreateDatabase](../../../includes/createdatabase.md)]
13+
# Step 2: Create an SQL database for pymssql Python development
14+
15+
Create an SQL database using either Azure SQL or SQL Server.
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+
- [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/github/codespaces-blank?quickstart=1).
23+
- `pymssql` package from PyPI.
24+
25+
## Create an SQL database
26+
27+
The samples in this next section only work with the AdventureWorks schema, on either Microsoft SQL Server or Azure SQL Database.
28+
29+
### [Azure SQL Database](#tab/azure-sql)
30+
31+
[Create an SQL database in minutes using the Azure portal](/azure/azure-sql/database/single-database-create-quickstart)
32+
33+
### [Microsoft SQL Server](#tab/sql-server)
34+
35+
[Microsoft SQL Server Samples on GitHub](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks)
36+
37+
---
38+
39+
> [!IMPORTANT]
40+
> Don't forget to get the credentials for the database you create.
41+
42+
## Next steps
43+
44+
> [!div class="nextstepaction"]
45+
> [Step 3: Proof of concept connecting to SQL using pymssql](step-3-proof-of-concept-connecting-to-sql-using-pymssql.md)

0 commit comments

Comments
 (0)