Public
Edited
Feb 21, 2023
3 stars
Insert cell
Insert cell
Insert cell
class DuckDBClientS3 extends DuckDBClient {
static async of(s3_config = {}, s3_sources = {}, sources = {}, config) {
const db = await super.of(sources, config);
// ref https://duckdb.org/docs/sql/configuration
for (let [k, v] of Object.entries(s3_config)) await db.query(`SET s3_${k}='${v}'`);
for (let [k, s] of Object.entries(s3_sources)) {
const p = Array.isArray(s) ? `str_split('${s.join(",")}', ',')` : `'${s}'`;
await db.query(`CREATE TABLE ${k} AS SELECT * FROM read_parquet(${p})`);
}
return db;
}
}
Insert cell
Insert cell
client = DuckDBClientS3.of(
{ region, access_key_id, secret_access_key },
{ "electricity_2018": "s3://linna/parquet/electricity_2018.parquet" },
{ "gaiai": FileAttachment("gaia-sample.arrow") }
)
Insert cell
client
SELECT
count(*) AS n
FROM electricity_2018
Insert cell
import { region, access_key_id, secret_access_key } from "@kimmolinna/duckdb-parquet-and-aws-s3"
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more