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
description: Connect to Azure SQL database using the ODBC driver and pyodbc or manage Azure SQL instances with the management API.
5
4
author: lisawong19
6
5
ms.author: liwong
7
-
manager: douge
8
-
ms.date: 07/11/2017
9
-
ms.topic: article
10
-
ms.prod: azure
11
-
ms.technology: azure
6
+
manager: routlaw
7
+
ms.date: 01/09/2018
8
+
ms.topic: reference
12
9
ms.devlang: python
13
10
ms.service: sql-database
14
11
---
@@ -17,44 +14,60 @@ ms.service: sql-database
17
14
18
15
## Overview
19
16
20
-
Work with data stored in [Azure SQL Database](/azure/sql-database/sql-database-technical-overview) from Python with the Microsoft ODBC driverand pyodbc.
17
+
Work with data stored in [Azure SQL Database](/azure/sql-database/sql-database-technical-overview) from Python with the pyodbc [ODBC database driver](https://github.com/mkleehammer/pyodbc/wiki/Drivers-and-Driver-Managers). View our [quickstart](https://docs.microsoft.com/azure/sql-database/sql-database-connect-query-python) on connecting to an Azure SQL database and using Transact-SQL statements to query data and getting started [sample](https://github.com/mkleehammer/pyodbc/wiki/Getting-started) with pyodbc.
21
18
22
-
## Client ODBC driver and pyodbc
19
+
## Install ODBC driver and pyodbc
23
20
24
21
```bash
25
22
pip install pyodbc
26
23
```
27
-
More details about installing the python and database communication libraries can be found [here](https://docs.microsoft.com/azure/sql-database/sql-database-connect-query-python#install-the-python-and-database-communication-libraries).
24
+
More [details](https://docs.microsoft.com/azure/sql-database/sql-database-connect-query-python#install-the-python-and-database-communication-libraries) about installing the python and database communication libraries.
28
25
29
-
### Example
26
+
##Connect and execute a SQL query
30
27
31
-
Connect to a SQL database and select all records in a table.
selectsql ="SELECT * FROM SALES"# SALES is an example table name
46
-
cursor.execute(selectsql)
47
41
```
48
42
49
-
## Management API
43
+
### Execute a SQL query
44
+
45
+
```python
46
+
cursor.execute("SELECT TOP 20 pc.Name as CategoryName, p.name as ProductName FROM [SalesLT].[ProductCategory] pc JOIN [SalesLT].[Product] p ON pc.productcategoryid = p.productcategoryid")
pyodbc works with other ORMs such as [SQLAlchemy](http://docs.sqlalchemy.org/en/latest/dialects/mssql.html?highlight=pyodbc#module-sqlalchemy.dialects.mssql.pyodbc) and [Django](https://github.com/lionheart/django-pyodbc/).
0 commit comments