D1 database in non-worker enviroment

I'm attempting to use D1 database outside of the workers environment, such as Node.js, but this is leading to several issues - especially the lack of direct bindings.
2 Replies
Chaika
Chaika3w ago
?d1-remote-connections
SuperHelpflare
D1 is based on SQLite, which does not natively support remote connections and isn't MySQL/PostgreSQL wire compatible, nor does D1 itself offer that functionality. As such, your options are: Cloudflare API (https://developers.cloudflare.com/api/operations/cloudflare-d1-query-database) using API tokens. Benefits: Less setup required. Drawbacks: All requests have to go back to Cloudflare's core, so request latency is far from optimal from some locations. You would also be subject to the API Rate limit of 1200 requests per 5 minutes. Your own worker to proxy requests to your D1 Database. Could be tightly bound to your application/database schema or just accept any query. Benefits: Faster, and may execute queries closer to your database (improving performance). Drawbacks: More work to set up, and more work to secure (need to write your own authentication).

Did you find this page helpful?