Skip to content

Commit bd492bf

Browse files
Mandukhai-Alimaaianmcookclaude
authored
Add MotherDuck examples using MotherDuck ADBC driver (#138)
* fix * fix duckdb quickstarts * Fix MotherDuck quickstart review findings - Let the driver read MOTHERDUCK_TOKEN itself instead of passing motherduck.token from each example. This fixes the C++ segfault and the misleading Java error when the variable is unset, and gives every language the same driver error message - Fix the region lookup in the READMEs: md_user_info() is a table function - Restructure the customize step to match the other quickstarts - List the MotherDuck account after the tool prerequisites, as the JavaScript README and the other cloud database quickstarts do - Restore --level user in the C++ and Ruby install commands - Restore the arrow alternatives in the R example - Revert the unrelated JVM args change in the Kotlin DuckDB and MotherDuck build files - Restore the Kotlin and Scala README list formatting Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Ian Cook <ianmcook@gmail.com> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 96c8955 commit bd492bf

106 files changed

Lines changed: 550 additions & 948 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/data/databases.json‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@
5353
},
5454
"duckdb": {
5555
"name": "DuckDB",
56-
"parent": "duckdb",
57-
"display_name_when_parent": "DuckDB-compatible systems",
58-
"protocol_description": "This directory contains examples showing how to use ADBC to connect {language} applications to DuckDB-compatible systems.",
59-
"source_systems_intro": "The examples included here cover the following systems:"
56+
"parent": null
6057
},
6158
"exasol": {
6259
"name": "Exasol",
@@ -83,7 +80,7 @@
8380
},
8481
"motherduck": {
8582
"name": "MotherDuck",
86-
"parent": "duckdb"
83+
"parent": null
8784
},
8885
"mssql": {
8986
"name": "Microsoft SQL Server",

‎README.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ Simple examples showing how to use ADBC to connect, run a query, and return the
5050
- [Databricks](https://github.com/columnar-tech/adbc-quickstarts/tree/by-database/databricks)
5151
- [DataFusion](https://github.com/columnar-tech/adbc-quickstarts/tree/by-database/datafusion)
5252
- [Apache Druid](https://github.com/columnar-tech/adbc-quickstarts/tree/by-database/druid)
53-
- DuckDB-compatible systems
54-
- [DuckDB](https://github.com/columnar-tech/adbc-quickstarts/tree/by-database/duckdb)
55-
- [MotherDuck](https://github.com/columnar-tech/adbc-quickstarts/tree/by-database/motherduck)
53+
- [DuckDB](https://github.com/columnar-tech/adbc-quickstarts/tree/by-database/duckdb)
5654
- [Exasol](https://github.com/columnar-tech/adbc-quickstarts/tree/by-database/exasol)
5755
- Apache Arrow Flight SQL-compatible systems
5856
- [Apache Doris](https://github.com/columnar-tech/adbc-quickstarts/tree/by-database/doris)
@@ -61,6 +59,7 @@ Simple examples showing how to use ADBC to connect, run a query, and return the
6159
- [Sail](https://github.com/columnar-tech/adbc-quickstarts/tree/by-database/sail)
6260
- [StarRocks](https://github.com/columnar-tech/adbc-quickstarts/tree/by-database/starrocks)
6361
- [MariaDB](https://github.com/columnar-tech/adbc-quickstarts/tree/by-database/mariadb)
62+
- [MotherDuck](https://github.com/columnar-tech/adbc-quickstarts/tree/by-database/motherduck)
6463
- [Microsoft SQL Server](https://github.com/columnar-tech/adbc-quickstarts/tree/by-database/mssql)
6564
- MySQL-compatible systems
6665
- [MySQL](https://github.com/columnar-tech/adbc-quickstarts/tree/by-database/mysql)

‎cpp/README.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ Simple C++ examples showing how to use ADBC to connect, run a query, and return
3333
- [Databricks](./databricks)
3434
- [DataFusion](./datafusion)
3535
- [Apache Druid](./druid)
36-
- [DuckDB-compatible systems](./duckdb)
37-
- [DuckDB](./duckdb/duckdb)
38-
- [MotherDuck](./duckdb/motherduck)
36+
- [DuckDB](./duckdb)
3937
- [Exasol](./exasol)
4038
- [Apache Arrow Flight SQL-compatible systems](./flightsql)
4139
- [Apache Doris](./flightsql/doris)
@@ -44,6 +42,7 @@ Simple C++ examples showing how to use ADBC to connect, run a query, and return
4442
- [Sail](./flightsql/sail)
4543
- [StarRocks](./flightsql/starrocks)
4644
- [MariaDB](./mariadb)
45+
- [MotherDuck](./motherduck)
4746
- [Microsoft SQL Server](./mssql)
4847
- [MySQL-compatible systems](./mysql)
4948
- [MySQL](./mysql/mysql)

‎cpp/duckdb/README.md‎

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,54 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
-->
1616

17-
<!--
18-
⚠️ DO NOT EDIT THIS FILE MANUALLY ⚠️
19-
This file is auto-generated by .github/scripts/generate_readmes.py
20-
To update, modify .github/data/databases.json or .github/data/languages.json
21-
-->
17+
# Connecting C++ and DuckDB with ADBC
18+
19+
## Instructions
2220

23-
# Connecting C++ to DuckDB-compatible systems with ADBC
21+
### Prerequisites
2422

25-
This directory contains examples showing how to use ADBC to connect C++ applications to DuckDB-compatible systems.
23+
1. [Install Pixi](https://pixi.prefix.dev/latest/)
2624

27-
## Source systems covered
25+
1. [Install dbc](https://docs.columnar.tech/dbc/getting_started/installation/)
2826

29-
The examples included here cover the following systems:
27+
### Connect to DuckDB
3028

31-
- [DuckDB](./duckdb)
32-
- [MotherDuck](./motherduck)
29+
1. Install the DuckDB ADBC driver:
3330

34-
## Instructions
31+
```sh
32+
dbc install --level user duckdb
33+
```
34+
35+
1. Customize the C++ program `main.cpp` as needed
36+
- Change the connection arguments in the `AdbcDatabaseSetOption()` calls
37+
- Set `path` to the location of the DuckDB database file you want to query, or keep it set to `games.duckdb` to use the database file included with this example
38+
- If you changed the database file, also change the SQL SELECT statement in `AdbcStatementSetSqlQuery()`
39+
40+
1. Build and run the C++ program:
41+
42+
Using Make:
43+
```sh
44+
pixi run make
45+
./duckdb_demo
46+
```
47+
48+
Or using CMake:
49+
```sh
50+
pixi run cmake -B build
51+
pixi run cmake --build build
52+
./build/duckdb_demo
53+
```
54+
55+
### Clean up
56+
57+
1. Clean build artifacts:
58+
59+
Using Make:
60+
```sh
61+
pixi run make clean
62+
```
3563

36-
Each subdirectory contains its own README with specific instructions.
64+
Using CMake:
65+
```sh
66+
rm -rf build
67+
```

‎cpp/duckdb/duckdb/README.md‎

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)