HomeMogDBMogDB StackUqbar
v3.1

Documentation:v3.1

Supported Versions:

Other Versions:

psycopg2.connect()

Function

This method creates a database session and returns a new connection object.

Prototype

conn=psycopg2.connect(dbname="test",user="postgres",password="secret",host="127.0.0.1",port="5432")

Parameter

Table 1 psycopg2.connect parameters

Keyword Description
dbname Database name.
user Username.
password Password.
host Database IP address. The default type is UNIX socket.
port Connection port number. The default value is 5432.
sslmode SSL mode, which is used for SSL connection.
sslcert Path of the client certificate, which is used for SSL connection.
sslkey Path of the client key, which is used for SSL connection.
sslrootcert Path of the root certificate, which is used for SSL connection.

Return Value

Connection object (for connecting to the openGauss DB instance)

Examples

For details, see Example: Common Operations.

Copyright © 2011-2024 www.enmotech.com All rights reserved.