Skip to content

Commit 73e4ee0

Browse files
authored
Specify Encrypt=yes
1 parent 0692d67 commit 73e4ee0

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎docs/connect/python/pyodbc/step-3-proof-of-concept-connecting-to-sql-using-pyodbc.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "Step 3: Connecting to SQL using pyodbc"
33
description: "Step 3 is a proof of concept, which shows how you can connect to SQL Server using Python and pyODBC. The basic examples demonstrate selecting and inserting data."
44
author: David-Engel
55
ms.author: v-davidengel
6-
ms.date: "03/24/2022"
6+
ms.date: 09/16/2022
77
ms.prod: sql
88
ms.technology: connectivity
99
ms.topic: conceptual
@@ -29,7 +29,8 @@ server = 'tcp:myserver.database.windows.net'
2929
database = 'mydb'
3030
username = 'myusername'
3131
password = 'mypassword'
32-
cnxn = pyodbc.connect('DRIVER={ODBC Driver 18 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
32+
# ENCRYPT defaults to yes starting in ODBC Driver 18. It's good to always specify ENCRYPT=yes on the client side to avoid MITM attacks.
33+
cnxn = pyodbc.connect('DRIVER={ODBC Driver 18 for SQL Server};SERVER='+server+';DATABASE='+database+';ENCRYPT=yes;UID='+username+';PWD='+ password)
3334
cursor = cnxn.cursor()
3435

3536
```

0 commit comments

Comments
 (0)