Query D1 outside of a worker

How can I query D1 outside of a worker, from another program?
I know I can use wrangler - npx wrangler d1 execute <db> --command="SELECT * FROM TABLE", but it is in a human-readable format. How can I export this data? Is there any API?

Your options are:

1 → The Cloudflare API Query Endpoint (Cloudflare API Documentation), with the upside of needing less setup, 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. This is what wrangler uses internally.

2 → Create a worker to proxy requests to your D1 Database. Either tightly bound to your application/schema or loose and just accepting any query. This would allow your worker to execute potentially closer to your D1 Database and avoid the api rate limit, with the downside of paying for each query as a worker invocation.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.