Return a PostgreSQL connection URI for the local server.
(&self)
| 83 | |
| 84 | /// Return a PostgreSQL connection URI for the local server. |
| 85 | pub fn connection_uri(&self) -> String { |
| 86 | match &self.endpoint { |
| 87 | ServerEndpoint::Tcp(addr) => tcp_connection_uri(*addr, &self.startup_config), |
| 88 | #[cfg(unix)] |
| 89 | ServerEndpoint::Unix(path) => { |
| 90 | let host = path.parent().unwrap_or_else(|| Path::new("/tmp")); |
| 91 | let port = parse_unix_socket_port(path).unwrap_or(5432); |
| 92 | format!( |
| 93 | "postgresql://{}@/{}?host={}&port={}&sslmode=disable", |
| 94 | self.startup_config.username, |
| 95 | self.startup_config.database, |
| 96 | percent_encode_query_value(&host.display().to_string()), |
| 97 | port |
| 98 | ) |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | /// Alias for [`connection_uri`](Self::connection_uri). |
| 104 | pub fn database_url(&self) -> String { |
no test coverage detected