Having Trouble Getting D1 to Work in Local Development with Drizzle ORM?
Everything works fine when I run drizzle migrate or use Drizzle Studio. Oddly enough, D1 also works perfectly after deploying to a Worker. However, it doesn't function in local development mode.
For context, I'm using React Router v7 along with the Wrangler Vite plugin.
Any ideas or suggestions would be greatly appreciated!
Here is my wrangler.jsonc
.dev.vars / .env
Here is my api code.

3 Replies
Does querying your database without drizzle work?
Did you setup your local database?
npx wrangler d1 create DB —local
It seems lile drizzle did not or could not init your database.
(Written on my phone, code untestet)Afaik Drizzle doesn't support loading the local sqlite db that is created by Wrangler.
I had to implement something similar to what is discussed here:
https://github.com/drizzle-team/drizzle-orm/discussions/1545
GitHub
How can I use Drizzle Studio with Cloudflare D1 in local environmen...
I am using Drizzle and Cloudflare D1 in my project and I like Drizzle a lot. And while I was trying Drizzle Studio, I found it connected to live database instead of local dev environment. I'd l...
Directly querying also did not work. Getting the same error.
Well that's interesting, I will try it myself, thanks for the Help