sqlload 0.45.0

SQL data loading tooling.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Run SQL statements in one session.

use crate::adapters::snowflake::models::SnowflakeDestination;
use crate::http::errors::ApiError;
use crate::sql_api::main::execute_script::execute_script;
use crate::sql_api::main::execute_sql::execute_sql;

/// Run `statements` in order in one session, so `BEGIN` ... `COMMIT` among them is one transaction.
pub(in crate::adapters) async fn run_statements(
    destination: &SnowflakeDestination,
    statements: &[String],
) -> Result<(), ApiError> {
    match statements {
        [] => Ok(()),
        [statement] => execute_sql(&destination.sql, statement).await.map(|_| ()),
        _ => execute_script(&destination.sql, statements).await,
    }
}