Skip to content

Commit

Permalink
Persist duckdb data
Browse files Browse the repository at this point in the history
  • Loading branch information
nullxone committed Oct 31, 2024
1 parent b4b8339 commit 19b9f8f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions connector-definition/connector-metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ supportedEnvironmentVariables:
- name: FEATURE_MIN_INSTANCES
description: Minimum number of instances to keep running (set to 1 to keep one instance running at all times)
defaultValue: 1
- name: DUCKDB_URL
description: Where to store the DuckDB database. Do not change this to outside the persist-data directory or data may not be persisted on connector restarts.
defaultValue: /etc/connector/persist-data/duck.db
commands: {}
dockerComposeWatch:
# Rebuild the container if a new package restore is required because package[-lock].json changed
Expand Down
8 changes: 5 additions & 3 deletions ndc-duckduckapi/src/duckduckapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@ import { Registry } from "prom-client";

import * as lambdaSdk from "@hasura/ndc-lambda-sdk/connector";

import { CAPABILITIES_RESPONSE, DUCKDB_CONFIG } from "./constants";
import { CAPABILITIES_RESPONSE } from "./constants";
import { do_get_schema } from "./handlers/schema";
import { do_explain } from "./handlers/explain";
import { perform_query, plan_queries } from "./handlers/query";
import { generateConfig } from "./generate-config";
import { Connection, Database } from "duckdb-async";

// Make a connection manager
const DUCKDB_URL = "duck.db"; // process.env["DUCKDB_URL"] as string || "duck.db";
const DUCKDB_URL = "duck.db";
let db: Database;
export async function getDB() {
if (!db) {
db = await Database.create(DUCKDB_URL);
db = await Database.create(
(process.env["DUCKDB_URL"] as string) ?? DUCKDB_URL
);
}
return db;
}
Expand Down

0 comments on commit 19b9f8f

Please sign in to comment.