-
(Optional) Create an access token in MotherDuck and save it as the environment variable
motherduck_tokenas 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.
-
Install the DuckDB ADBC driver:
dbc install duckdb
-
Customize the Go program
main.goas needed- Change the connection arguments in the
NewDatabase()call- Set
pathto the name of a MotherDuck database (prefixed withmd:), or keep it set tomd:sample_datato use MotherDuck's sample data
- Set
- Change the SQL SELECT statement in
stmt.SetSqlQuery()to query the tables in your database
- Change the connection arguments in the
-
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"