News for hackers. Stuff that matters.
Re:Python Workers redux: fast cold starts, packages, and a u... by wg0 on Thursday December 11, 2025 @03:58AM (#46229123)
If anyone from cloudflare comes here - it's not possible to create D1 databases on the fly and interact them because databases must be mentioned in the worker bindings.

This hampers the per user databases workflow.

Would be awesome if a fix lands.

Re:Python Workers redux: fast cold starts, packages, and a u... by ashwindharne on Thursday December 11, 2025 @04:45AM (#46229433)
I'm always a little hesitant to use D1 due to some of these constraints. I know I may not ever hit 10GB for some of my side projects so I just neglect sharding, but also it unsettles me that it's a hard cap.
Re:Python Workers redux: fast cold starts, packages, and a u... by dom96 on Thursday December 11, 2025 @04:52AM (#46229471)
(I work at Cloudflare, but not on D1)

I believe this is possible, you can create D1 databases[1] using Cloudflare's APIs and then deploy a worker using the API as well[2].

1 - https://developers.cloudflare.com/api/resources/d1/subresour...

2 - https://developers.cloudflare.com/api/resources/workers/subr...

Re:Python Workers redux: fast cold starts, packages, and a u... by ewuhic on Thursday December 11, 2025 @06:59AM (#46230323)
Hey, would you happen to know if/when D1 can get support for ICU (https://sqlite.org/src/dir/ext/icu) and transactions?
Re:Python Workers redux: fast cold starts, packages, and a u... by kentonv on Thursday December 11, 2025 @08:25AM (#46231078)
Transactions are supported in Durable Objects. In fact, with DO you are interacting with the SQLite database locally and synchronously, so transactions are essentially free with no possibility of conflicts and no worry about blocking other queries.

Extensions are easy to enable, file a bug on https://github.com/cloudflare/workerd . (Though this one might be trickier than most as we might have to do some build engineering.)

Re:Python Workers redux: fast cold starts, packages, and a u... by ewuhic on Thursday December 11, 2025 @01:54PM (#46235467)
Re DO - I am definitely not rewriting my web wasm rust-sqlx app to use DO.

Re filing an issue - sounds straightforward, will do!

Re:Python Workers redux: fast cold starts, packages, and a u... by kentonv on Thursday December 11, 2025 @07:09PM (#46239231)
You can run your wasm app in a DO, same as you run it in a Worker.
Re:Python Workers redux: fast cold starts, packages, and a u... by wg0 on Thursday December 11, 2025 @05:11AM (#46229579)
Thank you! That's great and it is possible but... With some limitations.

The idea is from sign up form to a D1 Database that can be accessed from the worker itself.

That's not possible without updating worker bindings like you showed and further - there is an upper limit of 5000 bindings per worker and just 5000 users then becomes the upper limit although D1 allows 50,000 databases easily with further possible by requesting a limit increase.

edit: Missed opening.

Re:Python Workers redux: fast cold starts, packages, and a u... by educhana on Thursday December 11, 2025 @06:21AM (#46230044)
Why not durable objects? I think it's the recommended pattern for having a db per user
Re:Python Workers redux: fast cold starts, packages, and a u... by kentonv on Thursday December 11, 2025 @08:22AM (#46231043)
Try Durable Objects. D1 is actually just a thin layer over Durable Objects. In the past D1 provided a lot of DX benefits like better observability, but those are increasingly being merged back into DO directly.

What is a Durable Object? It's just a Worker that has a name, so you can route messages specifically to it from other Workers. Each one also has its own SQLite database attached. In fact, the SQLite database is local, so you can query it synchronously (no awaits), which makes a lot of stuff faster and easier. You can easily create millions of Durable Objects.

(I am the lead engineer for Workers.)