Skip to content

Commit dd9b227

Browse files
committed
[SFi-DC-LAA agent] SFI/DC run
1 parent 0c30931 commit dd9b227

1 file changed

Lines changed: 31 additions & 31 deletions

File tree

articles/postgresql/connectivity/connect-python.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: This quickstart provides several Python code samples you can use to
44
author: gkasar
55
ms.author: gkasar
66
ms.reviewer: maghan
7-
ms.date: 08/27/2025
7+
ms.date: 04/07/2026
88
ms.service: azure-database-postgresql
99
ms.subservice: connectivity
1010
ms.topic: quickstart
@@ -14,7 +14,7 @@ ms.custom:
1414
- devx-track-python
1515
- passwordless-python
1616
- sfi-ropc-blocked
17-
ms.devlang: python
17+
ms.devlang: "python"
1818
---
1919

2020
# Quickstart: Use Python to connect and query data in Azure Database for PostgreSQL
@@ -65,7 +65,7 @@ python3 -m venv .venv
6565
source .venv/bin/activate
6666
```
6767

68-
> [!NOTE]
68+
> [!NOTE]
6969
> Ensure the virtual environment is activated before you run any `python -m pip instalL...` commands; using `python -m pip` (not a bare `pip`) ensures packages install into the same interpreter/venv you use to run the examples.
7070
7171
---
@@ -152,40 +152,40 @@ Optional: create a `requirements.txt` with these entries and install with `pytho
152152

153153
1. Get database connection information.
154154

155-
1. In the [Azure portal](https://portal.azure.com/), search for and select your Azure Database for PostgreSQL flexible server instance name.
156-
1. On the server's **Overview** page, copy the fully qualified **Server name**. The fully qualified **Server name** is always of the form *\<my-server-name>.postgres.database.azure.com*.
157-
1. On the left menu, under **Security**, select **Authentication**. Make sure your account is listed under **Microsoft Entra Admins**. If it isn't, complete the steps in [Configure Microsoft Entra integration on the server (passwordless only)](#configure-microsoft-entra-integration-on-the-server-passwordless-only).
155+
1. In the [Azure portal](https://portal.azure.com/), search for and select your Azure Database for PostgreSQL flexible server instance name.
156+
1. On the server's **Overview** page, copy the fully qualified **Server name**. The fully qualified **Server name** is always of the form *\<my-server-name>.postgres.database.azure.com*.
157+
1. On the left menu, under **Security**, select **Authentication**. Make sure your account is listed under **Microsoft Entra Admins**. If it isn't, complete the steps in [Configure Microsoft Entra integration on the server (passwordless only)](#configure-microsoft-entra-integration-on-the-server-passwordless-only).
158158

159159
1. Set environment variables for the connection URI elements:
160160

161-
### [Windows](#tab/cmd)
162-
163-
```cmd
164-
set DBHOST=<server-name>
165-
set DBNAME=<database-name>
166-
set DBUSER=<username>
167-
set SSLMODE=require
168-
```
169-
170-
### [macOS/Linux](#tab/bash)
171-
172-
```bash
173-
export DBHOST=<server-name>
174-
export DBNAME=<database-name>
175-
export DBUSER=<username>
176-
export SSLMODE=require
177-
```
178-
179-
Replace the following placeholder values in the commands:
180-
181-
- `<server-name>` with the value you copied from the Azure portal.
182-
- `<username>` with your Azure user name; for example: `john@contoso.com`.
183-
- `<database-name>` with the name of your Azure Database for PostgreSQL flexible server database. A default database named *postgres* was automatically created when you created your server. You can use that database or create a new database by using SQL commands.
161+
### [Windows](#tab/cmd)
162+
163+
```cmd
164+
set DBHOST=<server-name>
165+
set DBNAME=<database-name>
166+
set DBUSER=<username>
167+
set SSLMODE=require
168+
```
169+
170+
### [macOS/Linux](#tab/bash)
171+
172+
```bash
173+
export DBHOST=<server-name>
174+
export DBNAME=<database-name>
175+
export DBUSER=<username>
176+
export SSLMODE=require
177+
```
178+
179+
Replace the following placeholder values in the commands:
180+
181+
- `<server-name>` with the value you copied from the Azure portal.
182+
- `<username>` with your Azure user name; for example: `john@contoso.com`.
183+
- `<database-name>` with the name of your Azure Database for PostgreSQL flexible server database. A default database named *postgres* was automatically created when you created your server. You can use that database or create a new database by using SQL commands.
184184

185185
1. Sign in to Azure on your workstation. You can sign in using the Azure CLI, Azure PowerShell, or Azure Developer CLI.
186186

187-
The authentication code uses [`DefaultAzureCredential`](/python/api/azure-identity/azure.identity.defaultazurecredential) to authenticate with Microsoft Entra ID and get a token that authorizes you to perform operations on your server instance. `DefaultAzureCredential` supports a chain of authentication credential types. Among the credentials supported are credentials that you're signed in to developer tools with like the Azure CLI, Azure PowerShell, or Azure Developer CLI.
188-
187+
The authentication code uses [`DefaultAzureCredential`](/python/api/azure-identity/azure.identity.defaultazurecredential) to authenticate with Microsoft Entra ID and get a token that authorizes you to perform operations on your server instance. `DefaultAzureCredential` supports a chain of authentication credential types. Among the credentials supported are credentials that you're signed in to developer tools with like the Azure CLI, Azure PowerShell, or Azure Developer CLI.
188+
189189
#### [Password](#tab/password)
190190

191191
1. Copy the following code into an editor and save it in a file named *get_conn.py*.

0 commit comments

Comments
 (0)