Error querying planetscale db
Trying to get setup with drizzle and running into this error. There's not much info here so I'm not sure how to debug it
The query I'm trying to make at line 34 of +page.server.ts is:
8 Replies
can you show planetscale database.js connection code?
try to use custom fetch
GitHub
GitHub - planetscale/database-js: A Fetch API-compatible PlanetScal...
A Fetch API-compatible PlanetScale database driver - GitHub - planetscale/database-js: A Fetch API-compatible PlanetScale database driver
it may be a reason
just a first guess
Here's the connection code. It's entirely possible I'm missing a required piece of config
yeah
I guess you need to use a link I've sent you
there is an example for custom fetch for planetscale database.js driver
I can try it. The link says to use custom fetch for node versions older than 18 but I'm on 18.7.0
I'll read more of the planetscale databasejs docs because I haven't read them yet. I've only been using drizzle docs so far to get setup
I tried custom fetch, didn't work. I think its because its already using undici, the one they recommend passing as a custom fetch (can see this in the stack trace)
Boom got it working! Had to
import "dotenv/config";
to make sure dotenv was being used. I think my DATABASE_URL
env var was undefined and that's why the fetch failed.
Not sure where in that stack trace the error info is being left behind. If it's in drizzle somewhere it'd definitely help to flow that all the way back to the user. For example, when I used planetscale's examples in a separate file and executed that file with ts-node, this is the more complete error:
Yeah! great!
Thanks for the suggestion, will work on proper error providing from driver drizzle is using
Love this lib and I appreciate your help in looking into this! 🙏