You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/connect/python/mssql-python/python-sql-driver-mssql-python-quickstart.md
+45-18Lines changed: 45 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: This quickstart describes installing Python, and mssql-python then
4
4
author: dlevy-msft-sql
5
5
ms.author: dlevy
6
6
ms.reviewer: vanto, randolphwest
7
-
ms.date: 06/26/2025
7
+
ms.date: 07/09/2025
8
8
ms.service: sql
9
9
ms.subservice: connectivity
10
10
ms.topic: quickstart-sdk
@@ -14,7 +14,7 @@ ms.custom:
14
14
15
15
# Quickstart: Connect with the mssql-python driver for Python
16
16
17
-
In this quickstart, you connect a Python script to a database that you have created and loaded with sample data. You use the `mssql-python` driver for Python to connect to your database and perform basic operations, like reading and writing data.
17
+
In this quickstart, you connect a Python script to a database that you created and loaded with sample data. You use the `mssql-python` driver for Python to connect to your database and perform basic operations, like reading and writing data.
@@ -37,7 +37,7 @@ In this quickstart, you connect a Python script to a database that you have crea
37
37
Follow these steps to configure your development environment to develop an application using the `mssql-python` Python driver.
38
38
39
39
> [!NOTE]
40
-
> This driver uses the [TDS](/openspecs/windows_protocols/ms-tds/b46a581a-39de-4745-b076-ec4dbb7d13ec) protocol, which is enabled by default in SQL Server, SQL database in Fabric and Azure SQL Database. No extra configuration is required.
40
+
> This driver uses the [Tabular Data Stream (TDS)](/openspecs/windows_protocols/ms-tds/b46a581a-39de-4745-b076-ec4dbb7d13ec) protocol, which is enabled by default in SQL Server, SQL database in Fabric and Azure SQL Database. No extra configuration is required.
41
41
42
42
### Install the mssql-python package
43
43
@@ -47,19 +47,46 @@ Get the [`mssql-python` package](https://pypi.org/project/mssql-python/) from Py
47
47
48
48
1. Install the `mssql-python` package.
49
49
50
-
```bash
51
-
pip install mssql-python
52
-
```
50
+
### [Windows](#tab/windows)
51
+
52
+
```bash
53
+
pip install mssql-python
54
+
```
55
+
56
+
### [Linux](#tab/linux)
57
+
58
+
```bash
59
+
pip install mssql-python
60
+
```
61
+
62
+
### [macOS](#tab/mac)
63
+
64
+
```bash
65
+
brew install openssl
66
+
pip install mssql-python
67
+
```
68
+
69
+
---
70
+
71
+
### Install python-dotenv package
72
+
73
+
Get the [`python-dotenv`](https://pypi.org/project/python-dotenv/) from PyPI.
74
+
75
+
1. In the same directory, install the `python-dotenv` package.
76
+
77
+
```bash
78
+
pip install python-dotenv
79
+
```
53
80
54
81
### Check installed packages
55
82
56
83
You can use the PyPI command-line tool to verify that your intended packages are installed.
57
84
58
85
1. Check the list of installed packages with `pip list`.
59
86
60
-
```bash
61
-
pip list
62
-
```
87
+
```bash
88
+
pip list
89
+
```
63
90
64
91
### Create a SQL database
65
92
@@ -121,7 +148,7 @@ This quickstart requires the *[!INCLUDE [sssampledbnormal-md](../../../includes/
121
148
```
122
149
123
150
> [!TIP]
124
-
> The connection string used here largely depends on the type of SQL database you're connecting to. For more information on connection strings and their syntax, see [connection string syntax reference](../../ado-net/connection-string-syntax.md).
151
+
> The connection string used here largely depends on the type of SQL database you're connecting to. If you're connecting to an *Azure SQL Database* or a *SQL database in Fabric*, use the *ODBC* connection string from the connection strings tab. You might need to adjust the authentication type depending on your scenario. For more information on connection strings and their syntax, see [connection string syntax reference](../../odbc/dsn-connection-string-attribute.md).
125
152
126
153
### Execute a query
127
154
@@ -161,7 +188,7 @@ Use a SQL query string to execute a query and parse the results.
Copy file name to clipboardExpand all lines: docs/connect/python/pyodbc/python-sql-driver-pyodbc-quickstart.md
+25-11Lines changed: 25 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: This quickstart describes installing Python, and pyodbc then shows
4
4
author: dlevy-msft-sql
5
5
ms.author: dlevy
6
6
ms.reviewer: vanto, randolphwest
7
-
ms.date: 06/18/2025
7
+
ms.date: 07/09/2025
8
8
ms.service: sql
9
9
ms.subservice: connectivity
10
10
ms.topic: quickstart-sdk
@@ -14,7 +14,7 @@ ms.custom:
14
14
15
15
# Quickstart: Connect with the pyodbc driver for Python
16
16
17
-
In this quickstart, you connect a Python script to a database that you have created and loaded with sample data. You use the `pyodbc` driver for Python to connect to your database and perform basic operations, like reading and writing data.
17
+
In this quickstart, you connect a Python script to a database that you created and loaded with sample data. You use the `pyodbc` driver for Python to connect to your database and perform basic operations, like reading and writing data.
@@ -37,7 +37,7 @@ In this quickstart, you connect a Python script to a database that you have crea
37
37
Follow these steps to configure your development environment to develop an application using the `pyodbc` Python driver.
38
38
39
39
> [!NOTE]
40
-
> This driver uses the [TDS](/openspecs/windows_protocols/ms-tds/b46a581a-39de-4745-b076-ec4dbb7d13ec) protocol, which is enabled by default in SQL Server, SQL database in Fabric and Azure SQL Database. No extra configuration is required.
40
+
> This driver uses the [Tabular Data Stream (TDS)](/openspecs/windows_protocols/ms-tds/b46a581a-39de-4745-b076-ec4dbb7d13ec) protocol, which is enabled by default in SQL Server, SQL database in Fabric and Azure SQL Database. No extra configuration is required.
41
41
42
42
### Install the pyodbc package
43
43
@@ -47,19 +47,29 @@ Get the [`pyodbc` package](https://pypi.org/project/pyodbc/) from PyPI.
47
47
48
48
1. Install the `pyodbc` package.
49
49
50
-
```bash
51
-
pip install pyodbc
52
-
```
50
+
```bash
51
+
pip install pyodbc
52
+
```
53
+
54
+
### Install python-dotenv package
55
+
56
+
Get the [`python-dotenv`](https://pypi.org/project/python-dotenv/) from PyPI.
57
+
58
+
1. In the same directory, install the `python-dotenv` package.
59
+
60
+
```bash
61
+
pip install python-dotenv
62
+
```
53
63
54
64
### Check installed packages
55
65
56
66
You can use the PyPI command-line tool to verify that your intended packages are installed.
57
67
58
68
1. Check the list of installed packages with `pip list`.
59
69
60
-
```bash
61
-
pip list
62
-
```
70
+
```bash
71
+
pip list
72
+
```
63
73
64
74
### Create a SQL database
65
75
@@ -69,10 +79,14 @@ This quickstart requires the *[!INCLUDE [sssampledbnormal-md](../../../includes/
69
79
70
80
[Create a SQL database in minutes using the Azure portal](/azure/azure-sql/database/single-database-create-quickstart)
71
81
82
+
Copy the `ODBC` connection string from the *Connection strings* tab.
83
+
72
84
### [SQL database in Fabric](#tab/fabric-sql)
73
85
74
86
[Load AdventureWorks sample data in your SQL database in Microsoft Fabric](/fabric/database/sql/load-AdventureWorks-sample-data)
75
87
88
+
Copy the `ODBC` connection string from the *Settings* tab.
@@ -121,7 +135,7 @@ This quickstart requires the *[!INCLUDE [sssampledbnormal-md](../../../includes/
121
135
```
122
136
123
137
> [!TIP]
124
-
> The connection string used here largely depends on the type of SQL database you're connecting to. For more information on connection strings and their syntax, see [connection string syntax reference](../../ado-net/connection-string-syntax.md).
138
+
> The connection string used here largely depends on the type of SQL database you're connecting to. If you're connecting to an *Azure SQL Database* or a *SQL database in Fabric*, use the *ODBC* connection string from the connection strings tab. You might need to adjust the authentication type depending on your scenario. For more information on connection strings and their syntax, see [connection string syntax reference](../../odbc/dsn-connection-string-attribute.md).
125
139
126
140
### Execute a query
127
141
@@ -239,7 +253,7 @@ Execute an [INSERT](../../../t-sql/statements/insert-transact-sql.md) statement
239
253
```
240
254
241
255
> [!TIP]
242
-
> Optionally, you can use [`connection.rollback`](https://github.com/mkleehammer/pyodbc/wiki/Connection#rollback) to rollback the transaction.
256
+
> Optionally, you can use [`connection.rollback`](https://github.com/mkleehammer/pyodbc/wiki/Connection#rollback) to roll back the transaction.
243
257
244
258
1. Close the cursor and connection using [`cursor.close`](https://github.com/mkleehammer/pyodbc/wiki/Cursor#close) and [`connection.close`](https://github.com/mkleehammer/pyodbc/wiki/Connection#close).
0 commit comments