Announcing: DuckDB code snippet sets with MotherDuck Sharing

2023/11/28 - 3 min read

BY

The DuckDB Snippets site has been a source of inspiration for me as I’ve explored all the powerful analytic capabilities and SQL simplification in DuckDB. The site brings together code snippets from the community for DuckDB in SQL, Python, Bash and R to do things like Quickly Convert a CSV to Parquet, Query the Output of Another Process, Filter Column Names Using a Pattern and more,

Today, we’ve released a couple features that will make the site even more powerful: the ability to bundle multiple themed snippets together, and the ability to include a MotherDuck Share of public data with your snippet(s).

Sharing DuckDB Data with MotherDuck

MotherDuck Shares give you the power to share an updatable snapshot of an entire DuckDB database with other users by providing them with a secret URL. We’ve seen them be used inside companies to give colleagues access to data and publicly like the authors of the DuckDB in Action book have chosen to do [see page 26 in the free book].

Here’s a snippet showing how to use DuckDB-specific SQL extensions from Michael Simons, one of the authors of the DuckDB book:

screenshot of duckdbsnippets.com code snippet of using DuckDB-specific SQL extensions

To see this code snippet quack into action [ha!], you can visit app.motherduck.com and sign up for a free MotherDuck account. Then you can copy the ATTACH, USE, and desired SELECT statements into your MotherDuck notebook to see the SQL in action. Note that you can also do this all in the DuckDB CLI if you prefer.

We encourage you to check these out, vote on the snippets you find most helpful and submit your own snippets with public data.

Bundle Multiple Snippets Together

If you’re a current DuckDB Snippets user, you probably already caught that the snippet I shared above bundled multiple code snippets together into a single set. You can now do that whether or not you have a MotherDuck Share link referenced.

Here’s an example from Simon Aubury, who is also writing an upcoming DuckDB book, on how to load remote parquet files into DuckDB:

screenshot of duckdbsnippets.com code snippets on loading remote parquet files into DuckDB

You can try out this snippet in MotherDuck or in the DuckDB CLI running on your laptop.

Simon also has other great snippets on Working with public REST APIs using DuckDB and Working with spatial data in DuckDB.

Thanks to the DuckDB Community

Thanks to the community for writing such great code snippets for the DuckDB Snippets site and voting on the snippets you like the most. Special thanks to Michael Simons, Michael Hunger, Simon Aubury and the MotherDuck DevRel team (Mehdi Ouazza, David Neal) for seeding these new-style snippets on the site. Looking forward to seeing what you submit!

CONTENT
  1. Sharing DuckDB Data with MotherDuck
  2. Bundle Multiple Snippets Together
  3. Thanks to the DuckDB Community

Start using MotherDuck now!

blog subscription icon

Subscribe to motherduck blog