Skip to main content

Connections Overview

flAPI supports multiple database connections through DuckDB's extensive ecosystem of extensions. Configure your connections in the @flapi.yaml file.

Basic Configuration

Connections are defined in the connections section of your @flapi.yaml:

connections:
my-connection-name:
init: |
# SQL commands to initialize the connection
INSTALL extension_name;
LOAD extension_name;
properties:
# Connection-specific properties
property1: value1
property2: value2

Configuration Options

OptionDescriptionRequiredDefault
initSQL commands to initialize the connection (e.g., loading extensions)No-
propertiesConnection-specific properties accessible in templatesNo-
max_connectionsMaximum number of concurrent connectionsNo5
timeoutConnection timeout in secondsNo30

Environment Variables

You can use environment variables in your connection configuration:

connections:
my-db:
properties:
username: ${DB_USER}
password: ${DB_PASSWORD}

Connection Pooling

flAPI automatically manages connection pools for each configured database:

connections:
my-db:
pool:
min_size: 1
max_size: 10
idle_timeout: 300

Health Checks

Configure health checks for your connections:

connections:
my-db:
health_check:
enabled: true
interval: 60
query: SELECT 1