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-ref-services/sql.md
+33-18Lines changed: 33 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: Connect to Azure SQL database using the ODBC driver and pyodbc or m
4
4
author: lisawong19
5
5
ms.author: liwong
6
6
manager: routlaw
7
-
ms.date: 01/05/2018
7
+
ms.date: 01/09/2018
8
8
ms.topic: reference
9
9
ms.devlang: python
10
10
ms.service: sql-database
@@ -14,47 +14,62 @@ ms.service: sql-database
14
14
15
15
## Overview
16
16
17
-
Work with data stored in [Azure SQL Database](/azure/sql-database/sql-database-technical-overview) from Python with the Microsoft ODBC driver and pyodbc. View our [quickstart](https://docs.microsoft.com/azure/sql-database/sql-database-connect-query-python) and getting started [sample](https://github.com/Azure-Samples/sql-database-python-manage).
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.
18
+
19
+
20
+
## Connecting to ORMs
21
+
22
+
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/).
23
+
18
24
19
25
## Install ODBC driver and pyodbc
20
26
21
27
```bash
22
28
pip install pyodbc
23
29
```
24
-
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).
30
+
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.
25
31
26
-
###Connect and execute an SQL query
32
+
## Connect and execute a SQL query
27
33
28
-
Connect to a SQL database and select all records in a table.
selectsql ="SELECT * FROM SALES"# SALES is an example table name
43
-
cursor.execute(selectsql)
44
47
```
45
48
46
-
## Management API
49
+
### Execute a SQL query
50
+
51
+
```python
52
+
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")
0 commit comments