Skip to content

Latest commit

 

History

History
55 lines (38 loc) · 1.94 KB

File metadata and controls

55 lines (38 loc) · 1.94 KB

Connecting Go and MotherDuck with ADBC

Instructions

Prerequisites

  1. Create a MotherDuck account

  2. Install Go

  3. Install dbc

  4. (Optional) Create an access token in MotherDuck and save it as the environment variable motherduck_token as described at Authenticating to MotherDuck. If you skip this step, a browser window will open each time you connect, asking you to log in or confirm access.

Connect to MotherDuck

  1. Install the DuckDB ADBC driver:

    dbc install duckdb
  2. Customize the Go program main.go as needed

    • Change the connection arguments in the NewDatabase() call
      • Set path to the name of a MotherDuck database (prefixed with md:), or keep it set to md:sample_data to use MotherDuck's sample data
    • Change the SQL SELECT statement in stmt.SetSqlQuery() to query the tables in your database
  3. Run the Go program:

    go mod tidy
    go run main.go

Note

If MotherDuck reports that you are not using a compatible DuckDB version, you can install the specific version it requires by running:

dbc install "duckdb=X.Y.Z"