Skip to content

[Feature request] Environment variables in duckdb CLI #4038

@mskyttner

Description

@mskyttner

To facilitate making system specific settings in duckdb CLI, a feature allowing to make settings using values from system environment variables would be convenient.

For example in a CLI session when issuing initial PRAGMA statements for setting threads and memory limit or location of temp files, these settings could be made from system environment variables.

Another similar use case is connection strings, such as when using duckdb CLI with local object storage and setting connection information for an S3 backend.

Consider running duckdb -init statements.sql with these contents:

load '/extensions/httpfs.duckdb_extension';
.shell echo "Number of CPUs: $(nproc --all)  # could be used for PRAGMA threads setting?"
set s3_endpoint=$MINIO_ENDPOINT;
set s3_access_key_id=$MINIO_USER;
set s3_secret_access_key=$MINIO_PASS;
set s3_use_ssl=false;
set s3_region='';
set s3_url_style='path';
.timer on
select count(*) from 's3://$MINIO_BUCKET/*.parquet';

If direct variable substitution is out of scope, could the environment variables for $MINIO_* that are set on the host be set through a getenv or similar function for picking up and using these in the duckdb CLI?

When packaging duckdb CLI, for example in a container, a mechanism to allow configuring settings through environment variables would be very useful.

Identity Disclosure:

  • Full Name: Markus Skyttner
  • Affiliation: KTH - Royal Instititute of Technology

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions