The database each host can reach
A container, a Vercel Function, and a Cloudflare Worker each limit where the data can be kept: a file on a volume, a database over the network, or a binding the host provides.
SQLite in a container
SQLite keeps the database in a file, so the file has to sit on a disk that outlives the process. In a container, mount a volume and keep the processes that open the file on one machine, because SQLite's WAL mode shares memory between them.
Vercel Functions
A Vercel Function writes only to a /tmp of its own instance, so its data goes to a database the function reaches over the network.
Cloudflare Workers
A Cloudflare Worker is compiled to wasm, where tokio has no networking. sqlx opens its connections with tokio's TcpStream, so a worker reaches its data through the bindings of wrangler.toml. The handlers take them from the Env that fetch receives: the Cloudflare template puts env.d1("DB") in its AppState and saves its count in D1, and KV and Durable Objects come from env.kv and env.durable_object in the same way.
For PostgreSQL, such as Supabase, Cloudflare's Hyperdrive gives the worker a connection string, and Cloudflare's tokio-postgres example connects to it over a worker::Socket. Cloudflare publishes no Rust example for MySQL over Hyperdrive.
Next
- Deploying builds and runs the server on each of these hosts.
- Hosted PostgreSQL and MySQL lists the connection settings of the databases a function reaches over the network.