Mike_W
Mike_W

Reputation: 11

Set file_search_path to environment variable

In DuckDB, is there a way to set the file_search_path using an environment variable? This would make sharing scripts among team members easier.

What I would like to be able to do is something like the following:

set file_search_path = '%userprofile%'

When I do this, DuckDB does not interpret the variable %userprofile%, it just sees it as a string.

Upvotes: 0

Views: 39

Answers (1)

Gabor Szarnyas
Gabor Szarnyas

Reputation: 5057

Try the getenv function. On UNIX, it works as follows. It should work on Windows too with the USERPROFILE set by the OS.

$ export USERPROFILE="test"
$ duckdb
SET file_search_path = getenv('USERPROFILE');
SELECT current_setting('file_search_path') AS p;
┌─────────┐
│    p    │
│ varchar │
├─────────┤
│ test    │
└─────────┘

Upvotes: 1

Related Questions