How to connect a SQL database to Workers

I’m guessing this will only be available via Argon Tunnel and not via standard Workers?

Right now you will need an Argo Tunnel, but it will work with any Workers subscription (free tier or paid).

1 Like

I built an Azure Cosmos DB client for Cloudflare workers:

It’s a neat idea, but it’s also a bit hacky, I’m not sure I would use that in the real world. Also, in my case (a PostgreSQL DB on AWS RDS), I would have to spin up an EC2 instance just to install cloudflared which is annoying.

It’s really a shame because I love Cloudflare Worker, the dev experience is top-notch, and not being able to query an SQL database is the only thing keeping me on AWS Lambda.

I guess there are only 2 ways to properly support SQL DBs:

  • add an HTTP API to the DBs themselves. I found this but they seem to have abandoned the idea since the last edit was in 2015
  • add a polyfill for Node.js’s net and tls module (I guess?) to the Cloudflare worker execution environment

For postgres databases check this out. Puts a API onto of your tables, views, functions, and procedures.
https://postgrest.org/en/stable/