Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The recommended client library for accessing Azure Database for PostgreSQL is the open-source JavaScript connection library for Azure Database for PostgreSQL. This library is a non-blocking PostgreSQL client for JavaScript, supporting pure JavaScript and optional native libpq bindings.
Learn more about Azure Database for PostgreSQL
Client package
Install the npm module
Use npm to install the PostgreSQL client module.
npm install pg
Example
This example opens a client connection and executes a simple query.
const pg = require('pg');
const connectionString =
'postgres://{username}@{server-name}:{password}@{server-name}.postgres.database.azure.com:5432/{database-name}?ssl=true';
const client = new pg.Client(connectionString);
client.connect();
const query = 'SELECT * FROM {table-name}';
client.query(query, (err, res) => {
console.log(res);
});
Samples
PostgreSQL | Description |
---|---|
JavaScript code snippets using PostgreSQL | Learn how to create a pool, execute a query, obtain an exclusive client, and more. |
For more code samples that use various Azure packages, explore the JavaScript samples.
Azure SDK for JavaScript