Closed
Description
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
Metadata
Metadata
Assignees
Labels
No labels