Created
November 22, 2024 12:53
-
-
Save mehd-io/f80476992d99a8b43966191de923b773 to your computer and use it in GitHub Desktop.
Duckdb as portable catalog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- ataching the remote database (268KB) | |
ATTACH 's3://us-prd-motherduck-open-datasets/content/duckdb-as-catalog/ducky_catalog.ddb'; | |
SHOW all tables; | |
-- queries the data | |
FROM ducky_catalog.customers limit 5; | |
-- Listing views | |
SELECT sql FROM duckdb_views() where temporary=false; | |
-- Example on how to create a secrets based on sso AWS creds | |
CREATE SECRET secret ( | |
TYPE S3, | |
PROVIDER CREDENTIAL_CHAIN, | |
CHAIN 'sso' | |
); | |
-- Example on how to create a view based on Postgres table using env variable | |
CREATE VIEW ducks AS | |
SELECT * FROM postgres_scan( | |
'dbname=' || getenv('PGDATABASE') || | |
' host=' || getenv('PGHOST') || | |
' user=' || getenv('PGUSER') || | |
' password=' || getenv('PGPASSWORD') || | |
' connect_timeout=10 sslmode=require', | |
'public', | |
'ducks' | |
); | |
-- connecting to MotherDuck and uploading your local db | |
ATTACH 'md:' | |
CREATE DATABASE cloud_ducky_catalog from ducky_catalog; | |
-- creating a MotherDuck share | |
CREATE SHARE share_ducky_catalog from cloud_ducky_catalog3 (ACCESS UNRESTRICTED, VISIBILITY HIDDEN, UPDATE AUTOMATIC); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment