Skip to content
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 Google Cloud Run/SQL #500

Closed
dakom opened this issue Jul 8, 2020 · 1 comment
Closed

Support Google Cloud Run/SQL #500

dakom opened this issue Jul 8, 2020 · 1 comment

Comments

@dakom
Copy link

dakom commented Jul 8, 2020

Picking up from #144 (comment)

I am using Cloud Run + Cloud SQL (postgres) and the connection string which worked with diesel does not work out of the box with sqlx. I format it like this:

//note: things in all caps, that aren't env vars, are configurable / global constants

let socket_path = std::env::var("DB_SOCKET_PATH").unwrap_or("/cloudsql".to_string());
let instance_connection = std::env::var("INSTANCE_CONNECTION_NAME").unwrap_or(MY_INSTANCE_NAME.to_string());
let full_socket_path = utf8_percent_encode(&format!("{}/{}", socket_path, instance_connection), NON_ALPHANUMERIC).to_string();

format!("postgres://{}:{}@{}/{}", DB_USER, DB_PASS, full_socket_path, DB_NAME);

Any tips appreciated! I haven't tried the PgConnectOptions approach yet

@dakom
Copy link
Author

dakom commented Jul 9, 2020

Closing this since PgConnectOptions (on master) works, so whatever bug there is would be in the parsing, not specific to google cloud sql

@dakom dakom closed this as completed Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant