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

Nextjs duckdb connection #35

Closed
selimsezr opened this issue Jul 18, 2024 · 4 comments
Closed

Nextjs duckdb connection #35

selimsezr opened this issue Jul 18, 2024 · 4 comments

Comments

@selimsezr
Copy link

Hi everyone I'm developing apps with nextjs but I have a connection problem. How can i solve this issue?

//api/dbCheck
import { Connection, Database } from "duckdb-async";
import path from "path";

export async function GET() {
     const dbPath = path.join(process.cwd(), "duckdb.db");
      console.log(dbPath);  
      async function simpleTest() {
   
      const db = await Database.create(dbPath);
     
      console.log(db.connect());
      }
      
      simpleTest();
  return Response.json({ message: "Hello, Next.js!" });
}
⨯ ./node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:43:1
Module not found: Can't resolve 'mock-aws-s3'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js
./node_modules/duckdb/lib/duckdb-binding.js
./node_modules/duckdb/lib/duckdb.js
./node_modules/duckdb-async/dist/duckdb-async.js
./src/app/api/dbCheck/route.ts
 GET /api/dbCheck 500 in 34ms
@jdbohrman
Copy link

Also an issue here and it seems tons of others are experiencing it

@antonycourtney
Copy link
Contributor

[ Reponse here also shared on DuckDb Discord in the nodejs channel]:
The issue with getting DuckDb working on Next.JS is really a downstream package issue (see this github issue: mapbox/node-pre-gyp#661 (comment) ). The raw duckdb nodeJS bindings have the same issue as far as I know, it really doesn't have anything to do with the use of duckdb-async, which is really just thin promise wrappers around the underlying Node.JS package. See this article and associated package from @tobilg for what's involved in getting DuckDb working on AWS Lambda (though I'm not sure if this works for NextJS): https://tobilg.com/using-duckdb-in-aws-lambda

I am going to close this issue since it's really not a duckdb-async specific issue as far as I can see.

@selimsezr
Copy link
Author

I tried with this library but does not work. This problem like bcryptjs problem but there are AWS libraries at duckDB. I connected with using expressJS

@tobilg
Copy link

tobilg commented Jul 20, 2024

I tried with this library but does not work. This problem like bcryptjs problem but there are AWS libraries at duckDB. I connected with using expressJS

I‘m pretty confident it works if you use https://www.npmjs.com/package/duckdb-lambda-x86 instead of the normal duckdb package…

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

4 participants