pub async fn connect<T>(
config: &str,
tls: T
) -> Result<Connection<Socket, T::Stream>, Error>where
T: MakeTlsConnect<Socket>,Expand description
Connect the pg_worm client to a postgres database.
You need to activate the connection by spawning it off into a new thread, only then will the client actually work.
You can connect to a database only once. If you try to connect again, the function will return an error.
Example
ⓘ
let conn = connect("my_db_url", NoTls).expect("db connection failed");
tokio::spawn(async move {
conn.await.expect("connection error")
});