Skip to content

Commit

Permalink
docs: use motherduck gaia dataset from a share (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz authored Jul 24, 2023
1 parent 62bf252 commit 303bf3e
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions dev/notebooks/motherduck.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"id": "1e618c1e-a6c4-41c7-a771-98a0fc2f68c8",
"metadata": {},
"source": [
"This notebook shows that Mosaic works with a serverless DuckDB using [MotherDuck](https://motherduck.com). To use this notebook, you need to have access to MotherDuck and the [Gaia dataset](http://cdn.gea.esac.esa.int/Gaia/gdr3/gaia_source/) in a specific database. We will make this notebook more general in the future."
"This notebook shows that Mosaic works with a serverless DuckDB using [MotherDuck](https://motherduck.com). We are using the [Gaia dataset](http://cdn.gea.esac.esa.int/Gaia/gdr3/gaia_source/) from a [share](https://motherduck.com/docs/key-tasks/querying-a-shared-motherduck-database)."
]
},
{
Expand All @@ -31,7 +31,10 @@
},
"outputs": [],
"source": [
"con = duckdb.connect(\"md:gaia-import\")\n",
"con = duckdb.connect()\n",
"\n",
"share = 'md:_share/gaia-import/c551f2da-3258-4387-ac43-f4be601850ac'\n",
"con.execute(f\"ATTACH '{share}' AS share\")\n",
"\n",
"con.execute(\"ATTACH ':memory:' AS local\")\n",
"# con.execute(\"ATTACH 'indexes.db' AS local\") # use a local database for the indexes"
Expand All @@ -51,7 +54,7 @@
"del spec[\"data\"]\n",
"\n",
"# we use a sample (code to create it below)\n",
"table = \"gaia-import.gaia_sample_5_percent_projected\"\n",
"table = \"share.gaia_sample_5_percent_projected\"\n",
"\n",
"spec[\"hconcat\"][0][\"vconcat\"][0][\"plot\"][0][\"data\"][\"from\"] = table\n",
"spec[\"hconcat\"][0][\"vconcat\"][1][\"hconcat\"][0][\"plot\"][0][\"data\"][\"from\"] = table\n",
Expand Down Expand Up @@ -103,6 +106,21 @@
"c.query(\"FORCE INSTALL motherduck\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b4c77342-c19c-4e83-9068-2e4b80191612",
"metadata": {},
"outputs": [],
"source": [
"# Show all tables in the share\n",
"\n",
"c = duckdb.connect()\n",
"c.execute(f\"ATTACH '{share}' AS share\")\n",
"c.execute(\"USE share\")\n",
"c.query(\"SHOW TABLES\")"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -112,7 +130,8 @@
},
"outputs": [],
"source": [
"# Create a table with the u and v columns with natural earth projection\n",
"# Create a table with the u and v columns with natural earth projection.\n",
"# This will not work in the share and assumes a specific setup.\n",
"\n",
"c = duckdb.connect(\"md:gaia-import\")\n",
"\n",
Expand Down Expand Up @@ -143,19 +162,6 @@
"\"\"\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b4c77342-c19c-4e83-9068-2e4b80191612",
"metadata": {},
"outputs": [],
"source": [
"# Show all remote tables\n",
"\n",
"c = duckdb.connect(\"md:gaia-import\")\n",
"c.query(\"SHOW TABLES\")"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit 303bf3e

Please sign in to comment.