Questions regarding access to D1 databases

Hello! I am a bit of a newbie when it comes to back-end, and I’ve just created my cloudflare account, trying to set up a project, and I’ve run into a bit of a roadblock. I was wondering if what I am trying to do is even possible.

My main issue stems from a piece of software that I have to use for this project. This software needs access to write to the DB and for it, it asks me for an IP, username, and password. Now I managed to get this working fine on a localhost, but I haven’t found any way to reveal/access the IP for my D1 database.
Is this because the D1 DBs use severless technology? I must admit I’m not very familiar with how serverless works. Is there any way to access the DB through an IP? The software is not really something I can bypass since it’s part of some propietary hardware.

I apologize if this is completely obvious, but I’m mainly front-end so I’m very out of my comfort zone lol.
Either way thanks y’all for your time!

The short answer to your question is that it probably won’t work.

D1 runs on SQlite and does not natively support remote connections, you’d have to go through an HTTP API, either the Cloudflare API query endpoint or creating a worker to proxy queries. It’s not postgres or mysql wire compatible. Your application most likely supports a specific database (like postgres), or uses a library and thus supports a few, but it’s very unlikely it supports D1’s specific setup, and the latency would likely be suboptimal as well/some applications are built with the assumption multiple queries are relatively cheap when the database is always nearby/way lower latency then D1 would be.

1 Like