-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Unix Domain Sockets for Postgres #144
Comments
I just wanted to take sqlx for a test ride and found this feature missing. Is there any chance for a release including this feature soon? I almost exclusively use databases with UDS. |
Likewise I would like this feature too. On GCP Cloud Run you can only connect to postgres using their cloud sql proxy which provides a UDS method: |
We'll get a patch release out in the next couple days. A couple things that landed on master require a bit of testing before we can push a build out. |
@mehcode I am also attempting to deploy my app to GCP Cloud Run and hitting a roadblock trying to connect via UDS. |
@dylanjt 0.3.5 should support UDS. What issue are you having? |
Its been a few weeks since I've looked at it. I couldn't find an URL format that it would allow connecting with last time and couldn't find anything documented in the sqlx repo. I read through the code such as sqlx-core/src/url.rs where there are some tests for connecting but none UDS. Also read through sqlx-core/src/postgres/connection.rs and there are some good comments there but none applicable to UDS. My plan was to look into this again when 0.4.0 came out since I saw there were some changes in master that may improve this. I remember seeing some API where you can skip an URL and just provide the various field values for the connection. It would be awesome if it were documented or there was a test case for UDS. Also very possible I missed it. Once this works I'd be happy to add documentation on how to get this working in GCP cloud run. |
Sorry for the lack of docs on it. It's actually just as specified in libpq (or it should be). See: https://www.postgresql.org/docs/9.3/libpq-connect.html#AEN39692
Definitely not pretty though. You're correct. On master we have It's a bit complicated to test this in CI. I haven't had the time to figure it out. |
I personally prefer the key word syntax as it doesn't need any
Btw. two major linux distributions (Ubuntu and Fedora) nowadays put the UDS under |
@mehcode got it, I'm starting to think this is a GCP Cloud Run issue and not related to sqlx. I hope you don't mind if I put my current status here regardless to rule out sqlx; I'm pulling my hair out on this. I was able to make this format to respond, as in I got an error about incorrect username/password:
So when I add the username:password parameters,
I get an error
And I get a new error (this one takes some time to fail): I have also tried manually appending |
I spent a bit of time and wasn't able to get it to work with cloud run 'cloud sql proxy'. I did get further using the percent encode where I encoded ':' in the path (which is part of the google postgres connection instance name) with %3A. But it just timed out. Good news though, google now offers VPC for cloud run. So you can setup private IP access to POSTGRES and then serverlesss VPC connectors as documented here: https://cloud.google.com/sql/docs/postgres/connect-run. Then you can tell sqlx to connect using a standard port 5432 TCP connection. I'm successfully running on google cloud run with sqlx this way. |
@dylanjt Why didn't you use key words all the way?
Everything can be encoded as parameter key words: You can even put the
|
Can you open a new issue about "GCP Cloud Run" ? If you can connect via |
@bikeshedder oddly enough this resulted in an authenticate error from PG: incorrect password for user postgres error; odd because I ended up taking the private IP route @dcardamo. This honestly feels cleaner, is more familiar to me, and was quick to setup. It certainly is a viable option in probably most GCP Cloud Run scenarios. @mehcode I would love to do this, I'm new to Rust but am diving in and am eager to contribute especially to awesome libraries like this that I actively use and follow. Once I stabilize my setup some more, I will loop back and dive into this issue again. |
(deleted comment here, moved to new issue: #500) |
As a reference for anyone who stumbles upon this, as suggested by @dakom in #500, one solution could be the use of This successfully connects a Cloud Run instance to Cloud SQL using a public IP in my case.
|
//cc @xcthulhu
The text was updated successfully, but these errors were encountered: