Skip to content

Connect to EMQX Tables via PostgreSQL

EMQX Tables supports access via the PostgreSQL v3 wire protocol. This means most standard PostgreSQL-compatible tools and drivers can connect successfully at the protocol level.

Note: Although the connection utilizes the PostgreSQL wire protocol, EMQX Tables does not support the full PostgreSQL SQL dialect. Some standard SQL features or statements may not be available.

The connection is secured via TLS encryption.

Connection Parameters

Use the following information to connect:

You can find these credentials on your EMQX Tables Deployment Overview page in the Console.

  • Host: {YOUR_EMQX_TABLES_PUBLIC_HOST}
  • Port: 4002
  • Database: {YOUR_EMQX_TABLES_DB_NAME}
  • Username: {YOUR_EMQX_TABLES_USERNAME}
  • Password: {YOUR_EMQX_TABLES_PASSWORD}

PostgreSQL CLI (psql)

You can connect to EMQX Tables using the standard psql command-line tool:

bash
psql -h {HOST} -p 4003 -U {USER} -d {DB_NAME} -W

Connection String

Using this format in compatible client libraries like psycopg, rust-postgres, etc.:

text
host={HOST} port=4003 dbname={DB_NAME} user={USER} password=~~{PASSWORD}~~

URL Format

Use the following format with PostgreSQL-compatible JDBC or Python clients:

JDBC (Java):

text
jdbc:postgresql://{HOST}:4003/{DB_NAME}?user={USER}&password=~~{PASSWORD}~~&ssl=true

Python / Others:

text
postgresql://{USER}:~~{PASSWORD}~~@{HOST}:4003/{DB_NAME}

Postgres Foreign Data Wrapper (FDW)

You can integrate EMQX Tables into another PostgreSQL instance using postgres_fdw. Replace {HOST}, {DB_NAME}, {USER}, and {PASSWORD} with your actual EMQX Tables connection values.

sql
CREATE SERVER emqx_tables
FOREIGN DATA WRAPPER postgres_fdw
OPTIONS (host '{HOST}', dbname '{DB_NAME}', port '4003');

CREATE USER MAPPING FOR postgres
SERVER emqx_tables
OPTIONS (user '{USER}', password '~~{PASSWORD}~~');