Skip to content

Commit 87de878

Browse files
committed
Release v0.5.1, create database file based on env var
1 parent db57f6c commit 87de878

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

Diff for: ndc-duckduckapi/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ndc-duckduckapi/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hasura/ndc-duckduckapi",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"description": "SDK for the Hasura DDN DuckDuckAPI connector. Easily build a data API from any existing API by ETLing data into DuckDB.",
55
"author": "Hasura",
66
"license": "Apache-2.0",

Diff for: ndc-duckduckapi/src/duckduckapi.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,23 @@ import { do_explain } from "./handlers/explain";
2323
import { perform_query, plan_queries } from "./handlers/query";
2424
import { generateConfig } from "./generate-config";
2525
import { Connection, Database } from "duckdb-async";
26+
import fs from "fs-extra";
27+
import path from "path";
2628

2729
// Make a connection manager
2830
const DUCKDB_URL = "duck.db";
2931
let db: Database;
3032
export async function getDB() {
3133
if (!db) {
3234
const duckDBUrl = (process.env["DUCKDB_URL"] as string) ?? DUCKDB_URL;
35+
36+
const dirPath = path.dirname(duckDBUrl);
37+
if (dirPath !== ".") {
38+
await fs.ensureDir(dirPath);
39+
}
40+
3341
db = await Database.create(duckDBUrl);
34-
console.log("Created duckdb at", duckDBUrl);
42+
console.log("Database file at", duckDBUrl);
3543
}
3644
return db;
3745
}

0 commit comments

Comments
 (0)