PostgreSQL
PostgreSQL is a powerful, open-source, object-relational database system.
Resource Setup
Configure a PostgreSQL resource on the Meroxa Platform to securely abstract database credentials away from development. The Turbine application framework can leverage a PostgreSQL resource upstream as a source or downstream as a destination.
Networking
To use a PostgreSQL reource with a Turbine streaming application, it must be accessible to the Meroxa Platform by using any of the following secure methods:
Resource Configuration
To connect to your PostgreSQL database, first configure a PostgreSQL resource on the platform via the Meroxa Dashboard or CLI.
- CLI
- Dashboard
To create a new PostgreSQL resource on the platform use the meroxa resource create
command. The following example shows how to configure a PostgreSQL database as a resource named pg_db
using the Meroxa CLI.
$ meroxa resource create pg_db \
--type postgres \
--url postgres://username:[email protected]:port/database
Enabling Logical Replication
The following example shows you how to enable logical replication. You will to pass through the configuration using the metadata
flag when creating the PostreSQL resource. This is required if you wish to utilize Change Data Capture (CDC) with PostgreSQL as a source to your Turbine streaming application.
$ meroxa resource create pg_db_logical \
--type postgres \
--url postgres://username:[email protected]:port/database
--metadata '{"logical_replication":"true"}'
Optional Configurations
You can include additional configurations to your PostgreSQL resource depending on your database configuration and capabilities. Simply include any of the following relevant configurations in the meroxa resource create
command after providing the --url
.
--ca-cert string trusted certificates for verifying resource
--client-cert string client certificate for authenticating to the resource
--client-key string client private key for authenticating to the resource
--env string environment (name or UUID) where resource will be created
-h, --help help for create
-m, --metadata string resource metadata
--password string password
--ssh-private-key string SSH tunneling private key
--ssh-url string SSH tunneling address
--ssl use SSL
The following depicts an example of how to configure the PostgreSQL resource with SSL disabled:
$ meroxa resource create pg_db \
--type postgres \
--url postgres://username:[email protected]:5432/database \
--ssl false
Click the following link to directly access PostgreSQL resource creation in the dashboard.
Or, follow these steps to create a new PostgreSQL resource configuration on the platform in the dashboard:
- Sign in to your Meroxa account.
- Click the Resources tab.
- Click the Add a Resource button.
- Under the Resource Type dropdown, select PostgreSQL.
- Fill out Resource Name. We recommend naming it something descriptive.
- Provide the connection URL containing the following:
- PostgreSQL Username
- PostgreSQL Password
- PostgreSQL Host URL
- PostgreSQL Port (e.g. 5432)
- PostgreSQL Database Name
- Enable any optional configurations required by your PostgreSQL database (e.g., Logical Replication, Mutual TLS/SSL or SSH tunnel).
- Click the Save button.