tembo/cli/sqlx_utils.rs
1use sqlx::postgres::PgConnectOptions;
2
3pub struct SqlxUtils {}
4
5impl SqlxUtils {
6 pub async fn execute_sql(instance_name: String, sql: String) -> Result<(), anyhow::Error> {
7 let connect_options = PgConnectOptions::new()
8 .username("postgres")
9 .password("postgres")
10 .host(&format!("{}.local.tembo.io", instance_name))
11 .database("postgres");
12
13 let pool = sqlx::PgPool::connect_with(connect_options).await?;
14
15 sqlx::query(&sql).execute(&pool).await?;
16
17 Ok(())
18 }
19}