📄 Database Manager Package
Overview
The Database Manager package provides bricks for performing database operations. It supports PostgreSQL, MySQL, MariaDB, Oracle Database, Microsoft SQL Server, and SQLite.
Bricks
The package includes these bricks:
- Get Tables List: Lists tables in a database with row counts.
- Query Database: Executes SQL queries and returns results as a DataFrame.
- Extract Table: Extracts data from a table with filtering, sorting, and column selection options.
- Get Table Schema: Retrieves schema information for a table, including column details.
- Execute SQL Scripts: Runs SQL statements and returns results and status.
General Configuration
Using Environment Variables for Database Connections
If you don't provide database connection parameters as brick inputs, you can configure them using environment variables.
Step 1 — Create an environment file
Create an environment file in the flow project folder. You can name it anything you like (e.g. .env
, db.env
, or mysettings.env
).
Example: db.env
# Example database environment configuration
DB_NAME=mydatabase
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=myuser
DB_PASSWORD=mypassword
💡 For SQLite, only
DB_NAME
is required (e.g.,DB_NAME=mydb.sqlite
).
Step 2 — Reference the env file in CODED FLOWS
Inside the CODED FLOWS app, use the LOAD ENV control brick to load the file you created.
- Specify your env filename (
db.env
for example or whichever name you chose). - All defined variables become available to any bricks in the connected graph flow.
Step 3 — Use with prefix (optional)
If you enable the "Env variables prefix" option in the LOAD ENV brick, the system will automatically prepend the prefix and an underscore to each variable.
Example with prefix MYAPP
:
MYAPP_DB_NAME=mydatabase
MYAPP_DB_HOST=localhost
MYAPP_DB_PORT=5432
MYAPP_DB_USERNAME=myuser
MYAPP_DB_PASSWORD=mypassword
Bricks will then look for MYAPP_DB_NAME
, MYAPP_DB_HOST
, etc. instead of the default variable names.