pub struct PgExecutor { /* private fields */ }Expand description
PostgreSQL executor using sqlx.
Manages a connection pool and executes queries against PostgreSQL databases.
§Example
ⓘ
use nautilus_connector::PgExecutor;
#[tokio::main]
async fn main() -> nautilus_core::Result<()> {
let executor = PgExecutor::new("postgres://user:pass@localhost/mydb").await?;
// Use executor to run queries...
Ok(())
}Implementations§
Source§impl PgExecutor
impl PgExecutor
Sourcepub async fn new_with_options(
url: &str,
pool_options: ConnectorPoolOptions,
) -> Result<Self>
pub async fn new_with_options( url: &str, pool_options: ConnectorPoolOptions, ) -> Result<Self>
Create a new PostgreSQL executor with explicit pool overrides.
Any override not provided keeps the same default used by Self::new.
Sourcepub async fn execute_raw(&self, sql: &str) -> Result<()>
pub async fn execute_raw(&self, sql: &str) -> Result<()>
Execute a raw SQL statement with no result rows (e.g., DDL).
Sourcepub async fn execute_collect_unprepared(&self, sql: &Sql) -> Result<Vec<Row>>
pub async fn execute_collect_unprepared(&self, sql: &Sql) -> Result<Vec<Row>>
Execute a SQL query with sqlx statement persistence disabled.
This is reserved for raw/direct query paths that must stay compatible with poolers such as PgBouncer transaction pooling.
Sourcepub async fn execute_affected(&self, sql: &Sql) -> Result<usize>
pub async fn execute_affected(&self, sql: &Sql) -> Result<usize>
Execute a mutation SQL and return the number of affected rows.
Used when return_data = false — no RETURNING clause is emitted
so the affected-row count must come from the database result.
Trait Implementations§
Source§impl Executor for PgExecutor
Executor implementation backed by a PostgreSQL connection pool.
impl Executor for PgExecutor
Executor implementation backed by a PostgreSQL connection pool.
Source§type RowStream<'conn> = RowStream<'conn>
where
Self: 'conn
type RowStream<'conn> = RowStream<'conn> where Self: 'conn
The stream type yielding rows from query execution. Read more
Source§fn execute<'conn>(&'conn self, sql: &'conn Sql) -> Self::RowStream<'conn>
fn execute<'conn>(&'conn self, sql: &'conn Sql) -> Self::RowStream<'conn>
Execute a SQL query and return a stream of rows. Read more
Source§fn execute_owned(&self, sql: Sql) -> RowStream<'static>
fn execute_owned(&self, sql: Sql) -> RowStream<'static>
Execute a SQL query and return a row stream that owns its work. Read more
Source§fn execute_and_fetch<'conn>(
&'conn self,
mutation: &'conn Sql,
fetch: &'conn Sql,
) -> Self::RowStream<'conn>
fn execute_and_fetch<'conn>( &'conn self, mutation: &'conn Sql, fetch: &'conn Sql, ) -> Self::RowStream<'conn>
Execute a mutation SQL, drain its results, then execute a fetch SQL
on the same database connection and return the fetch rows. Read more
Source§fn execute_collect<'conn>(
&'conn self,
sql: &'conn Sql,
) -> BoxFuture<'conn, Result<Vec<Self::Row<'conn>>>>where
Self: 'conn,
fn execute_collect<'conn>(
&'conn self,
sql: &'conn Sql,
) -> BoxFuture<'conn, Result<Vec<Self::Row<'conn>>>>where
Self: 'conn,
Execute a SQL query and materialize all rows into a vector. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for PgExecutor
impl !UnwindSafe for PgExecutor
impl Freeze for PgExecutor
impl Send for PgExecutor
impl Sync for PgExecutor
impl Unpin for PgExecutor
impl UnsafeUnpin for PgExecutor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more