Inputs

The query function of PsqlProvider takes the following arguments:

  • query (str): A string containing the query to be executed against the POSTGRES database.
  • single_row (bool, optional): If True, the function will return only the first result.

Outputs

The query function returns either a list or a tuple of results, depending on whether single_row was set to True or not. If single_row was True, then the function returns a single result.

Authentication Parameters

The following authentication parameters are used to connect to the POSTGRES database:

  • user (str): The Postgres username.
  • password (str): The Postgres password.
  • host (str): The Postgres hostname.
  • dbname (str, optional): The name of the Postgres database.
  • port (str, optional): The Postgres server port.

Connecting with the Provider

In order to connect to the Postgres database, you will need to create a new user with the required permissions. Here’s how you can do this:

  1. Connect to the Postgresql server as a user with sufficient privileges to create a new user.
  2. Run the following command to create a new user: CREATE USER '<username>' WITH ENCRYPTED PASSWORD '<password>';
  3. Run the following command to create a database: CREATE DATABASE '<yourdbname>';;
  4. Grant the necessary permissions to the new user by running the following command: GRANT ALL PRIVILEGES ON <database>.* TO '<username>';

Notes