pub trait Executor {
type Row;
type QueryResult;
// Required methods
async fn execute(self, sql: &str) -> Result<Self::QueryResult, Error>;
async fn execute_with<T: ToString>(
self,
sql: &str,
arguments: &[T],
) -> Result<Self::QueryResult, Error>;
async fn fetch(self, sql: &str) -> Result<Vec<Self::Row>, Error>;
async fn fetch_with<T: ToString>(
self,
sql: &str,
arguments: &[T],
) -> Result<Vec<Self::Row>, Error>;
async fn fetch_one(self, sql: &str) -> Result<Self::Row, Error>;
async fn fetch_optional(self, sql: &str) -> Result<Option<Self::Row>, Error>;
async fn fetch_optional_with<T: ToString>(
self,
sql: &str,
arguments: &[T],
) -> Result<Option<Self::Row>, Error>;
}
Expand description
Executing queries against the database.
Required Associated Types§
Sourcetype QueryResult
type QueryResult
A type for the query result.
Required Methods§
Sourceasync fn execute(self, sql: &str) -> Result<Self::QueryResult, Error>
async fn execute(self, sql: &str) -> Result<Self::QueryResult, Error>
Executes the query and return the total number of rows affected.
Sourceasync fn execute_with<T: ToString>(
self,
sql: &str,
arguments: &[T],
) -> Result<Self::QueryResult, Error>
async fn execute_with<T: ToString>( self, sql: &str, arguments: &[T], ) -> Result<Self::QueryResult, Error>
Executes the query with arguments and return the total number of rows affected.
Sourceasync fn fetch(self, sql: &str) -> Result<Vec<Self::Row>, Error>
async fn fetch(self, sql: &str) -> Result<Vec<Self::Row>, Error>
Executes the query and return all the generated results.
Sourceasync fn fetch_with<T: ToString>(
self,
sql: &str,
arguments: &[T],
) -> Result<Vec<Self::Row>, Error>
async fn fetch_with<T: ToString>( self, sql: &str, arguments: &[T], ) -> Result<Vec<Self::Row>, Error>
Executes the query with arguments and return all the generated results.
Sourceasync fn fetch_one(self, sql: &str) -> Result<Self::Row, Error>
async fn fetch_one(self, sql: &str) -> Result<Self::Row, Error>
Executes the query and returns exactly one row.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<'c> Executor for &'c Pool<DatabaseDriver>
Available on crate feature orm-sqlx
only.
impl<'c> Executor for &'c Pool<DatabaseDriver>
Available on crate feature
orm-sqlx
only.type Row = SqliteRow
type QueryResult = <Sqlite as Database>::QueryResult
async fn execute(self, sql: &str) -> Result<Self::QueryResult, Error>
async fn execute_with<T: ToString>( self, sql: &str, arguments: &[T], ) -> Result<Self::QueryResult, Error>
async fn fetch(self, sql: &str) -> Result<Vec<Self::Row>, Error>
async fn fetch_with<T: ToString>( self, sql: &str, arguments: &[T], ) -> Result<Vec<Self::Row>, Error>
async fn fetch_one(self, sql: &str) -> Result<Self::Row, Error>
async fn fetch_optional(self, sql: &str) -> Result<Option<Self::Row>, Error>
async fn fetch_optional_with<T: ToString>( self, sql: &str, arguments: &[T], ) -> Result<Option<Self::Row>, Error>
Implementors§
Source§impl<'c> Executor for &'c mut DatabaseConnection
Available on crate feature orm-sqlx
only.
impl<'c> Executor for &'c mut DatabaseConnection
Available on crate feature
orm-sqlx
only.