Skip to content

Commit

Permalink
.{db,ddb,duckdb}
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Mar 18, 2024
1 parent 66dd5ba commit 82037c1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/client/stdlib/duckdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,10 @@ async function insertFile(database, name, file, options) {
if (/\.parquet$/i.test(file.name)) {
return await connection.query(`CREATE VIEW '${name}' AS SELECT * FROM parquet_scan('${file.name}')`);
}
// Lastly, let DuckDB guess: it may be a .duckdb (or .db or .ddb) database file.
return await connection.query(`ATTACH '${file.name}' AS ${name} (READ_ONLY)`);
if (/\.(db|ddb|duckdb)$/i.test(file.name)) {
return await connection.query(`ATTACH '${file.name}' AS ${name} (READ_ONLY)`);
}
throw new Error(`unknown file type: ${file.mimeType}`);
}
} finally {
await connection.close();
Expand Down

0 comments on commit 82037c1

Please sign in to comment.