Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) Add support for attaching a MotherDuck database with token in settings or config #444

Merged
merged 12 commits into from
Sep 24, 2024

Conversation

guenp
Copy link
Collaborator

@guenp guenp commented Sep 20, 2024

Add support for attaching a MotherDuck database and pass an arbitrary token via config, settings or path.

Example profiles.yml:

test:
  outputs:
    user:
      threads: 1
      type: duckdb
      path: /tmp/data.duckdb
      attach:
       - path: md:my_db
         type: motherduck
      settings:
        motherduck_token: "{{ env_var('motherduck_token_1') }}"

Right now, this fails with an error:

Runtime Error
  setting 'motherduck_token' can only be set during initialization

This is because the SET command happens after the ATTACH. Similarly, when passing the token via config, this also fails, because the motherduck extension is not yet loaded when running duckdb.connect. Lastly, passing the token via the path also fails because it's passed to the ATTACH command directly and this also does not let you set the token.

Therefore, currently the only way to attach a MotherDuck database is to have the motherduck_token env var set.

After some discussion with Josh we decided:

  • re-order the attach block and the plugin initialization block inside of initialize_db (so that plugins were initialized before attaches)
  • SET the MotherDuck token before the md: attach happens. Similar to how the config is updated when connecting to a MD path.

Copy link
Collaborator

@jwills jwills left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me @guenp!

@guenp guenp merged commit acf622d into master Sep 24, 2024
33 checks passed
@guenp guenp deleted the guenp/md-attach branch September 24, 2024 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants