Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional option support for Database instance creation #21

Closed
tomsanbear opened this issue Nov 22, 2023 · 6 comments
Closed

Additional option support for Database instance creation #21

tomsanbear opened this issue Nov 22, 2023 · 6 comments

Comments

@tomsanbear
Copy link

Thanks for this library, saved me some time from having to promisify the original callback based library.

One thing missing however is full support of the options supported in the original database constructor (https://github.com/duckdb/duckdb-node/blob/55a3602f42a0019b25d2ec9c48b3c6e6bf55802f/lib/duckdb.d.ts#L147C7-L147C7). I'd love to contribute this code to the repository if you are open, but didn't see any contribution guidelines. If there aren't any specific guidellines then I can probably open an PR for this later this week.

Thanks!

@jlarmstrongiv
Copy link

That’d be fantastic! I am running into out of memory errors, because I cannot configure database options

const db = new duckdb.Database(':memory:', {
    "access_mode": "READ_WRITE",
    "max_memory": "512MB",
    "threads": "4"
}, (err) => {
  if (err) {
    console.error(err);
  }
});

@jlarmstrongiv
Copy link

jlarmstrongiv commented Feb 8, 2024

Some options can’t be changed with SET statements while running either

ERROR	[Error: Invalid Input Error: Cannot change allow_unsigned_extensions setting while database is running] {
  errno: -1,
  code: 'DUCKDB_NODEJS_ERROR',
  errorType: 'Invalid Input'
}

I downloaded the official extensions locally—I’d like to be able to run them

See docs for example with the duckdb library https://duckdb.org/duckdb-docs.pdf

@jlarmstrongiv
Copy link

jlarmstrongiv commented Feb 8, 2024

It looks like the options are passed straight through to duckdb, so using a // @ts-expect-error will work

  // @ts-expect-error Argument of type 'Config' is not assignable to parameter of type 'number'.
  const db = await Database.create(filePath, config);

antonycourtney added a commit that referenced this issue Feb 16, 2024
@antonycourtney
Copy link
Contributor

Hi folks, thanks for surfacing this! Looks like the type of the Database constructor was widened in the underlying node bindings in a recent DuckDb release. I've started a duckdb-latest branch in this repository and just committed a fix to address this issue. Will promote this branch (and publish it to npm) when the node bindings for 0.10.0 are published.
Thanks for reporting the issue, the constructive interim workarounds, and for your patience!

@tgdn
Copy link

tgdn commented Sep 22, 2024

Any updates on this?

@elefeint
Copy link
Collaborator

This was fixed back in 0.10.2, so passing the full configuration dictionary works now, consistent with duckdb-node:

const db = await Database.create(':memory:', {
    "access_mode": "READ_WRITE",
    "max_memory": "512MB",
    "threads": "12"
}, (err) => {
    if (err) {
        console.error(err);
    }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants