Connecting to the Database (Using SSL)
When you use psycopy2 to connect to the GaussDB Kernel server, you can enable SSL to encrypt the communication between the client and server. To enable SSL, you must have the server certificate, client certificate, and private key files. For details on how to obtain these files, see related documents and commands of OpenSSL.
Use the .ini file (the **configparser **package of Python can parse this type of configuration file) to save the configuration information about the database connection.
Add SSL connection parameters sslmode, sslcert, sslkey, and **sslrootcert **to the connection options.
- sslmode: Table 1
- sslcert: client certificate path
- sslkey: client key path
- sslrootcert: root certificate path
Use the psycopg2.connect function to obtain the connection object.
Use the connection object to create a cursor object.
Table 1 sslmode options
Feedback