[][src]Trait sqlx::Executor

pub trait Executor {
    type Database: Database + ?Sized;
    fn send<'e, 'q>(
        &'e mut self,
        command: &'q str
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'e + Send>>
    where
        'q: 'e
;
fn execute<'e, 'q>(
        &'e mut self,
        query: &'q str,
        args: <Self::Database as Database>::Arguments
    ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + 'e + Send>>
    where
        'q: 'e
;
fn fetch<'e, 'q>(
        &'e mut self,
        query: &'q str,
        args: <Self::Database as Database>::Arguments
    ) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::Row, Error>> + 'e + Send>>
    where
        'q: 'e
;
fn describe<'e, 'q>(
        &'e mut self,
        query: &'q str
    ) -> Pin<Box<dyn Future<Output = Result<Describe<Self::Database>, Error>> + 'e + Send>>
    where
        'q: 'e
; fn fetch_optional<'e, 'q>(
        &'e mut self,
        query: &'q str,
        args: <Self::Database as Database>::Arguments
    ) -> Pin<Box<dyn Future<Output = Result<Option<<Self::Database as Database>::Row>, Error>> + 'e + Send>>
    where
        'q: 'e
, { ... }
fn fetch_one<'e, 'q>(
        &'e mut self,
        query: &'q str,
        args: <Self::Database as Database>::Arguments
    ) -> Pin<Box<dyn Future<Output = Result<<Self::Database as Database>::Row, Error>> + 'e + Send>>
    where
        'q: 'e
, { ... } }

Encapsulates query execution on the database.

Implemented primarily by crate::Pool.

Associated Types

Loading content...

Required methods

fn send<'e, 'q>(
    &'e mut self,
    command: &'q str
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'e + Send>> where
    'q: 'e, 

Send a raw SQL command to the database.

This is intended for queries that cannot or should not be prepared (ex. BEGIN).

Does not support fetching results.

fn execute<'e, 'q>(
    &'e mut self,
    query: &'q str,
    args: <Self::Database as Database>::Arguments
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + 'e + Send>> where
    'q: 'e, 

Execute the query, returning the number of rows affected.

fn fetch<'e, 'q>(
    &'e mut self,
    query: &'q str,
    args: <Self::Database as Database>::Arguments
) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::Row, Error>> + 'e + Send>> where
    'q: 'e, 

Executes the query and returns a [Stream] of Row.

fn describe<'e, 'q>(
    &'e mut self,
    query: &'q str
) -> Pin<Box<dyn Future<Output = Result<Describe<Self::Database>, Error>> + 'e + Send>> where
    'q: 'e, 

Analyze the SQL query and report the inferred bind parameter types and returned columns.

Loading content...

Provided methods

fn fetch_optional<'e, 'q>(
    &'e mut self,
    query: &'q str,
    args: <Self::Database as Database>::Arguments
) -> Pin<Box<dyn Future<Output = Result<Option<<Self::Database as Database>::Row>, Error>> + 'e + Send>> where
    'q: 'e, 

Executes the query and returns up to resulting record.

fn fetch_one<'e, 'q>(
    &'e mut self,
    query: &'q str,
    args: <Self::Database as Database>::Arguments
) -> Pin<Box<dyn Future<Output = Result<<Self::Database as Database>::Row, Error>> + 'e + Send>> where
    'q: 'e, 

Execute the query and return at most one resulting record.

Loading content...

Implementors

impl<'_, DB> Executor for &'_ Pool<DB> where
    DB: Database
[src]

type Database = DB

impl<DB> Executor for Pool<DB> where
    DB: Database
[src]

type Database = DB

Loading content...