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
# Quickstart: Use Java to connect to and query data in Azure Database for PostgreSQL - Single Server
15
-
This quickstart demonstrates how to connect to an Azure Database for PostgreSQL using a Java application. It shows how to use SQL statements to query, insert, update, and delete data in the database. The steps in this article assume that you are familiar with developing using Java, and are new to working with Azure Database for PostgreSQL.
15
+
16
+
In this quickstart, you connect to an Azure Database for PostgreSQL using a Java application. It shows how to use SQL statements to query, insert, update, and delete data in the database. The steps in this article assume that you are familiar with developing using Java, and are new to working with Azure Database for PostgreSQL.
16
17
17
18
## Prerequisites
18
-
This quickstart uses the resources created in either of these guides as a starting point:
19
-
-[Create DB - Portal](quickstart-create-server-database-portal.md)
20
-
-[Create DB - Azure CLI](quickstart-create-server-database-azure-cli.md)
21
19
22
-
You also need to:
23
-
- Download the [PostgreSQL JDBC Driver](https://jdbc.postgresql.org/download.html) matching your version of Java and the Java Development Kit.
24
-
- Include the PostgreSQL JDBC jar file (for example postgresql-42.1.1.jar) in your application classpath. For more information, see [classpath details](https://jdbc.postgresql.org/documentation/head/classpath.html).
20
+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio).
21
+
22
+
- Completion of [Quickstart: Create an Azure Database for PostgreSQL server in the Azure portal](quickstart-create-server-database-portal.md) or [Quickstart: Create an Azure Database for PostgreSQL using the Azure CLI](quickstart-create-server-database-azure-cli.md).
23
+
24
+
-[PostgreSQL JDBC Driver](https://jdbc.postgresql.org/download.html) - match your version of Java and the Java Development Kit.
25
+
-[Classpath details](https://jdbc.postgresql.org/documentation/head/classpath.html) - Include the PostgreSQL JDBC jar file (for example postgresql-42.1.1.jar) in your application classpath.
25
26
26
27
## Get connection information
27
28
Get the connection information needed to connect to the Azure Database for PostgreSQL. You need the fully qualified server name and login credentials.
28
29
29
-
1.Log in to the [Azure portal](https://portal.azure.com/).
30
-
2. From the left-hand menu in Azure portal, select **All resources**, and then search for the server you have created (such as **mydemoserver**).
31
-
3. Select the servername.
32
-
4. From the server's **Overview** panel, make a note of the **Server name** and **Server admin login name**. If you forget your password, you can also reset the password from this panel.
33
-

30
+
1.In the [Azure portal](https://portal.azure.com/), search for and select the server you have created (such as **mydemoserver**).
31
+
32
+
1. From the server's **Overview** panel, make a note of the **Server name** and **Admin username**. If you forget your password, you can also reset the password from this panel.
33
+
34
+

34
35
35
36
## Connect, create table, and insert data
36
37
Use the following code to connect and load the data into the database using the function with an **INSERT** SQL statement. The methods [getConnection()](https://www.postgresql.org/docs/7.4/static/jdbc-use.html), [createStatement()](https://jdbc.postgresql.org/documentation/head/query.html), and [executeQuery()](https://jdbc.postgresql.org/documentation/head/query.html) are used to connect to the database, drop, and create the table. The [prepareStatement](https://jdbc.postgresql.org/documentation/head/query.html) object is used to build the insert commands, with setString() and setInt() to bind the parameter values. Method [executeUpdate()](https://jdbc.postgresql.org/documentation/head/update.html) runs the command for each set of parameters.
# Quickstart: Use Node.js to connect and query data in Azure Database for PostgreSQL - Single Server
15
-
This quickstart demonstrates how to connect to an Azure Database for PostgreSQL using a [Node.js](https://nodejs.org/) application. It shows how to use SQL statements to query, insert, update, and delete data in the database. The steps in this article assume that you are familiar with developing using Node.js, and are new to working with Azure Database for PostgreSQL.
15
+
16
+
In this quickstart, you connect to an Azure Database for PostgreSQL using a Node.js application. It shows how to use SQL statements to query, insert, update, and delete data in the database. The steps in this article assume that you are familiar with developing using Node.js, and are new to working with Azure Database for PostgreSQL.
16
17
17
18
## Prerequisites
18
-
This quickstart uses the resources created in either of these guides as a starting point:
19
-
-[Create DB - Portal](quickstart-create-server-database-portal.md)
20
-
-[Create DB - CLI](quickstart-create-server-database-azure-cli.md)
21
19
22
-
You also need to:
23
-
- Install [Node.js](https://nodejs.org)
20
+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio).
21
+
22
+
- Completion of [Quickstart: Create an Azure Database for PostgreSQL server in the Azure portal](quickstart-create-server-database-portal.md) or [Quickstart: Create an Azure Database for PostgreSQL using the Azure CLI](quickstart-create-server-database-azure-cli.md).
23
+
24
+
-[Node.js](https://nodejs.org)
24
25
25
26
## Install pg client
26
27
Install [pg](https://www.npmjs.com/package/pg), which is a PostgreSQL client for Node.js.
@@ -38,11 +39,11 @@ npm list
38
39
## Get connection information
39
40
Get the connection information needed to connect to the Azure Database for PostgreSQL. You need the fully qualified server name and login credentials.
40
41
41
-
1.Log in to the [Azure portal](https://portal.azure.com/).
42
-
2. From the left-hand menu in Azure portal, select **All resources**, and then search for the server you have created (such as **mydemoserver**).
43
-
3. Select the servername.
44
-
4. From the server's **Overview** panel, make a note of the **Server name** and **Server admin login name**. If you forget your password, you can also reset the password from this panel.
45
-

42
+
1.In the [Azure portal](https://portal.azure.com/), search for and select the server you have created (such as **mydemoserver**).
43
+
44
+
1. From the server's **Overview** panel, make a note of the **Server name** and **Admin username**. If you forget your password, you can also reset the password from this panel.
45
+
46
+

46
47
47
48
## Running the JavaScript code in Node.js
48
49
You may launch Node.js from the Bash shell, Terminal, or Windows Command Prompt by typing `node`, then run the example JavaScript code interactively by copy and pasting it onto the prompt. Alternatively, you may save the JavaScript code into a text file and launch `node filename.js` with the file name as a parameter to run it.
Copy file name to clipboardExpand all lines: articles/postgresql/connect-python.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,15 +10,19 @@ ms.topic: quickstart
10
10
ms.date: 11/07/2019
11
11
---
12
12
13
-
# Use Python to connect and query data in Azure Database for PostgreSQL - Single Server
14
-
This quickstart demonstrates how to work with an Azure Database for PostgreSQL using Python on macOS, Ubuntu Linux, or Windows. The quickstart shows how to connect to the database and use SQL statements to query, insert, update, and delete data. The article assumes that you're familiar with Python, but new to working with Azure Database for PostgreSQL.
13
+
# Quickstart: Use Python to connect and query data in Azure Database for PostgreSQL - Single Server
14
+
15
+
In this quickstart, you work with an Azure Database for PostgreSQL using Python on macOS, Ubuntu Linux, or Windows. The quickstart shows how to connect to the database and use SQL statements to query, insert, update, and delete data. The article assumes that you're familiar with Python, but new to working with Azure Database for PostgreSQL.
15
16
16
17
## Prerequisites
17
-
- An Azure Database for PostgreSQL - Single Server, created by using the steps in [Quickstart: Create an Azure Database for PostgreSQL server in the Azure portal](quickstart-create-server-database-portal.md) or [Quickstart: Create an Azure Database for PostgreSQL using the Azure CLI](quickstart-create-server-database-azure-cli.md).
18
+
19
+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio).
20
+
21
+
- Completion of [Quickstart: Create an Azure Database for PostgreSQL server in the Azure portal](quickstart-create-server-database-portal.md) or [Quickstart: Create an Azure Database for PostgreSQL using the Azure CLI](quickstart-create-server-database-azure-cli.md).
18
22
19
23
-[Python](https://www.python.org/downloads/) 2.7.9+ or 3.4+.
20
24
21
-
-The latest update of [pip](https://pip.pypa.io/en/stable/installing/) package installer, installed using `pip install -U pip`.
The [psycopg2](https://pypi.python.org/pypi/psycopg2/) module enables connecting to and querying a PostgreSQL database, and is available as a Linux, macOS, or Windows [wheel](https://pythonwheels.com/) package. Install the binary version of the module, including all the dependencies. For more information about `psycopg2` installation and requirements, see [Installation](http://initd.org/psycopg/docs/install.html).
0 commit comments