DBrex connects to your database through Trino (formerly PrestoSQL), which acts as a distributed SQL query engine. This guide will help you set up and configure your database connection.
Trino uses a three-level hierarchy to organize data sources:
- Catalog: Configuration for accessing a specific data source
- Schema: Logical grouping of tables within a catalog
- Table: Individual data tables
This hierarchy is reflected in Trino's fully qualified naming: catalog.schema.table
A catalog in Trino represents a configured data source and consists of:
- Connector configuration
- Authentication credentials
- Connection properties
- Data source URL
Catalogs are defined through properties files in Trino's configuration directory. The filename becomes the catalog name (e.g., postgres.properties creates a catalog named "postgres").
Launch a mounted Trino container:
docker run --name trino \
-d \
-p 8080:8080 \
-v <YOUR_PATH>:/etc/trino/catalog \
trinodb/trino- Choose your connector from the official Trino connectors list
- Create a properties file in your mounted configuration directory:
- Filename format:
<connector_name>.properties - Example:
postgres.properties,mysql.properties, ...
- Filename format:
- Add the required configuration parameters for your chosen connector
Example PostgreSQL connector configuration:
connector.name=postgresql
connection-url=jdbc:postgresql://example.net:5432/database
connection-user=root
connection-password=secret- Restart the Trino container:
docker restart trino- Connect to Trino CLI and verify your catalog:
docker exec -it trino trinoSHOW catalogs;- Explore your data source:
-- List schemas in your catalog
SHOW SCHEMAS FROM catalog_name;
-- List tables in a schema
SHOW TABLES FROM catalog_name.schema_name;
To give DBrex access to your database, you must pass the catalog, the schema and the table name along with other parameters when starting the DBrex container. There are two options to pass the arguments:
- as command line arguments
docker run -d -v dbrex:/app/dbrex/data --name dbrex ghcr.io/janskn/dbrex:latest <args>- In a file called
args.json.
docker run -d -v dbrex:/app/dbrex/data -v <YOUR_PATH>:/app/dbrex/config --name dbrex ghcr.io/janskn/dbrex:latestThe argument names must be equivalent to the long option below. You can find an example here.
Warning
The columns in -q or --queries must be in format symbol_name.column_name as in the example.
Here is a list of all arguments:
| Option | Long Option | Description |
|---|---|---|
| -c | --catalog | Name of the data source |
| -s | --schema | Name of the schema of the catalog |
| -t | --table_name | Name of the source table |
| -r | --regex | RegEx pattern. Explicit use of parentheses, example: 'A1 A2 | A3' evaluates to '(A1 A2) | A3', instead use 'A1 (A2 | A3)' |
| -a | --alphabet | RegEx alphabet |
| -q | --queries | SQL queries separated by RegEx symbol. Must be same order as the alphabet |
| -o | --output_table | Name of the output table |
| -twt | --time_window_type | Time window type (countbased or sliding_window). Only countbased supported at this version |
| -twc | --tw_column | Name of the column for the time window selection. Values must be integer and in increasing order |
| -tws | --tw_size | Time window size |
| -sf | --sleep_for | sleep for n milliseconds after each execution to conserve resources |