Hi All. Hopefully this is the right place to ask this question: I'm working on a project where a l

Hi All. Hopefully this is the right place to ask this question:

I'm working on a project where a local python app uses the cloudflare D1 REST API (via cloudflare-python) to write data to D1 as the producer.

I then use cloudflare workers to query D1 to consume this data and display it on a web app.

D1 is amazing! Everything "works" however the D1 REST API via the python app seems quite slow, perhaps hitting some type of REST API rate limit? So my next step was to batch my D1 queries in the python app to reduce round trips, same as I do in my workers. But this does not appear to be supported via the rest API? https://developers.cloudflare.com/api/operations/cloudflare-d1-query-database

The REST API spec includes "Your SQL query. Supports multiple statements, joined by semicolons, which will be executed as a batch."
Great! But how do I pass in multiple params arrays for each different query? I definitely want to be using prepared statements here for injection safety.

I could write a new worker to make a bespoke API that I send my queries and params to, and then batch them via the worker, but I was hoping to avoid another worker to maintain.
Interact with Cloudflare's products and services via the Cloudflare API
Was this page helpful?