How to connect to postgresql via unix socket

Hey!

I want to execute kratos migrations in a google cloud build step. For this I am using the exec-wrapper docker image to set up a cloud sql proxy via a unix socket. The socket is found at /cloudsql/project-name:region:db

I would like to connect kratos to this socket using a connection string, e.g:
postgres://postgres:wvkGkrz84ieeMHnd@/cloudsql/project-name:region:db:5432/kratos

unfortunately this is not parsed correctly. Any pointers in the right direction? Thanks!

Yes, you can use pgcon style connection strings: https://github.com/jackc/pgconn

Thanks @hackerman, I managed to get it working with:

postgresql:///kratos?user=postgres&password=wvkGkrz84ieeMHnd&host=/cloudsql/project-name:region:db&port=5432

1 Like