mz_testdrive/action/postgres/
connect.rs1use anyhow::bail;
11
12use crate::action::{ControlFlow, State};
13use crate::parser::BuiltinCommand;
14use crate::util::postgres::postgres_client;
15
16pub async fn run_connect(
17 mut cmd: BuiltinCommand,
18 state: &mut State,
19) -> Result<ControlFlow, anyhow::Error> {
20 let name = cmd.args.string("name")?;
21 if name.starts_with("postgres://") {
22 bail!("connection name can not be url");
23 }
24
25 let url = cmd.args.string("url")?;
26 cmd.args.done()?;
27
28 let (client, _) = postgres_client(&url, state.default_timeout).await?;
29 state.postgres_clients.insert(name.clone(), client);
30 Ok(ControlFlow::Continue)
31}