[−][src]Struct sqlx::Pool
An asynchronous pool of SQLx database connections.
Implementations
impl<DB> Pool<DB> where
DB: Database,
[src]
DB: Database,
pub async fn connect(uri: &'_ str) -> Result<Pool<DB>, Error>
[src]
Creates a new connection pool with a default pool configuration and the given connection URI; and, immediately establishes one connection.
pub async fn connect_with(
options: <<DB as Database>::Connection as Connection>::Options
) -> Result<Pool<DB>, Error>
[src]
options: <<DB as Database>::Connection as Connection>::Options
) -> Result<Pool<DB>, Error>
Creates a new connection pool with a default pool configuration and the given connection options; and, immediately establishes one connection.
pub fn connect_lazy(uri: &str) -> Result<Pool<DB>, Error>
[src]
Creates a new connection pool with a default pool configuration and the given connection URI; and, will establish a connections as the pool starts to be used.
pub fn connect_lazy_with(
options: <<DB as Database>::Connection as Connection>::Options
) -> Pool<DB>
[src]
options: <<DB as Database>::Connection as Connection>::Options
) -> Pool<DB>
Creates a new connection pool with a default pool configuration and the given connection options; and, will establish a connections as the pool starts to be used.
pub fn acquire(
&self
) -> impl Future<Output = Result<PoolConnection<DB>, Error>> + 'static
[src]
&self
) -> impl Future<Output = Result<PoolConnection<DB>, Error>> + 'static
Retrieves a connection from the pool.
Waits for at most the configured connection timeout before returning an error.
pub fn try_acquire(&self) -> Option<PoolConnection<DB>>
[src]
Attempts to retrieve a connection from the pool if there is one available.
Returns None
immediately if there are no idle connections available in the pool.
pub async fn begin(&'_ self) -> Result<Transaction<'static, DB>, Error>
[src]
Retrieves a new connection and immediately begins a new transaction.
pub async fn try_begin(
&'_ self
) -> Result<Option<Transaction<'static, DB>>, Error>
[src]
&'_ self
) -> Result<Option<Transaction<'static, DB>>, Error>
Attempts to retrieve a new connection and immediately begins a new transaction if there is one available.
pub async fn close(&'_ self)
[src]
Ends the use of a connection pool. Prevents any new connections and will close all active connections when they are returned to the pool.
Does not resolve until all connections are closed.
pub fn is_closed(&self) -> bool
[src]
Returns true
if .close()
has been called on the pool, false
otherwise.
Trait Implementations
impl<'_, DB> Acquire<'static> for &'_ Pool<DB> where
DB: Database,
[src]
DB: Database,
type Database = DB
type Connection = PoolConnection<DB>
fn acquire(
self
) -> Pin<Box<dyn Future<Output = Result<<&'_ Pool<DB> as Acquire<'static>>::Connection, Error>> + 'static + Send>>
[src]
self
) -> Pin<Box<dyn Future<Output = Result<<&'_ Pool<DB> as Acquire<'static>>::Connection, Error>> + 'static + Send>>
fn begin(
self
) -> Pin<Box<dyn Future<Output = Result<Transaction<'static, DB>, Error>> + 'static + Send>>
[src]
self
) -> Pin<Box<dyn Future<Output = Result<Transaction<'static, DB>, Error>> + 'static + Send>>
impl<DB> Clone for Pool<DB> where
DB: Database,
[src]
DB: Database,
Returns a new Pool tied to the same shared connection pool.
impl<DB> Debug for Pool<DB> where
DB: Database,
[src]
DB: Database,
impl<'p, '_, DB> Executor<'p> for &'_ Pool<DB> where
DB: Database,
&'c mut <DB as Database>::Connection: for<'c> Executor<'c>,
<&'c mut <DB as Database>::Connection as Executor<'c>>::Database == DB,
[src]
DB: Database,
&'c mut <DB as Database>::Connection: for<'c> Executor<'c>,
<&'c mut <DB as Database>::Connection as Executor<'c>>::Database == DB,
type Database = DB
fn fetch_many<'e, 'q, E>(
self,
query: E
) -> Pin<Box<dyn Stream<Item = Result<Either<<DB as Database>::Done, <DB as Database>::Row>, Error>> + 'e + Send>> where
'q: 'e,
E: 'q + Execute<'q, <&'_ Pool<DB> as Executor<'p>>::Database>,
[src]
self,
query: E
) -> Pin<Box<dyn Stream<Item = Result<Either<<DB as Database>::Done, <DB as Database>::Row>, Error>> + 'e + Send>> where
'q: 'e,
E: 'q + Execute<'q, <&'_ Pool<DB> as Executor<'p>>::Database>,
fn fetch_optional<'e, 'q, E>(
self,
query: E
) -> Pin<Box<dyn Future<Output = Result<Option<<DB as Database>::Row>, Error>> + 'e + Send>> where
'q: 'e,
E: 'q + Execute<'q, <&'_ Pool<DB> as Executor<'p>>::Database>,
[src]
self,
query: E
) -> Pin<Box<dyn Future<Output = Result<Option<<DB as Database>::Row>, Error>> + 'e + Send>> where
'q: 'e,
E: 'q + Execute<'q, <&'_ Pool<DB> as Executor<'p>>::Database>,
fn prepare_with<'e, 'q>(
self,
sql: &'q str,
parameters: &'e [<<&'_ Pool<DB> as Executor<'p>>::Database as Database>::TypeInfo]
) -> Pin<Box<dyn Future<Output = Result<<<&'_ Pool<DB> as Executor<'p>>::Database as HasStatement<'q>>::Statement, Error>> + 'e + Send>> where
'q: 'e,
[src]
self,
sql: &'q str,
parameters: &'e [<<&'_ Pool<DB> as Executor<'p>>::Database as Database>::TypeInfo]
) -> Pin<Box<dyn Future<Output = Result<<<&'_ Pool<DB> as Executor<'p>>::Database as HasStatement<'q>>::Statement, Error>> + 'e + Send>> where
'q: 'e,
fn execute<'e, 'q, E>(
self,
query: E
) -> Pin<Box<dyn Future<Output = Result<<Self::Database as Database>::Done, Error>> + 'e + Send>> where
'q: 'e,
'c: 'e,
E: 'q + Execute<'q, Self::Database>,
[src]
self,
query: E
) -> Pin<Box<dyn Future<Output = Result<<Self::Database as Database>::Done, Error>> + 'e + Send>> where
'q: 'e,
'c: 'e,
E: 'q + Execute<'q, Self::Database>,
fn execute_many<'e, 'q, E>(
self,
query: E
) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::Done, Error>> + 'e + Send>> where
'q: 'e,
'c: 'e,
E: 'q + Execute<'q, Self::Database>,
[src]
self,
query: E
) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::Done, Error>> + 'e + Send>> where
'q: 'e,
'c: 'e,
E: 'q + Execute<'q, Self::Database>,
fn fetch<'e, 'q, E>(
self,
query: E
) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::Row, Error>> + 'e + Send>> where
'q: 'e,
'c: 'e,
E: 'q + Execute<'q, Self::Database>,
[src]
self,
query: E
) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::Row, Error>> + 'e + Send>> where
'q: 'e,
'c: 'e,
E: 'q + Execute<'q, Self::Database>,
fn fetch_all<'e, 'q, E>(
self,
query: E
) -> Pin<Box<dyn Future<Output = Result<Vec<<Self::Database as Database>::Row>, Error>> + 'e + Send>> where
'q: 'e,
'c: 'e,
E: 'q + Execute<'q, Self::Database>,
[src]
self,
query: E
) -> Pin<Box<dyn Future<Output = Result<Vec<<Self::Database as Database>::Row>, Error>> + 'e + Send>> where
'q: 'e,
'c: 'e,
E: 'q + Execute<'q, Self::Database>,
fn fetch_one<'e, 'q, E>(
self,
query: E
) -> Pin<Box<dyn Future<Output = Result<<Self::Database as Database>::Row, Error>> + 'e + Send>> where
'q: 'e,
'c: 'e,
E: 'q + Execute<'q, Self::Database>,
[src]
self,
query: E
) -> Pin<Box<dyn Future<Output = Result<<Self::Database as Database>::Row, Error>> + 'e + Send>> where
'q: 'e,
'c: 'e,
E: 'q + Execute<'q, Self::Database>,
fn prepare<'e, 'q>(
self,
query: &'q str
) -> Pin<Box<dyn Future<Output = Result<<Self::Database as HasStatement<'q>>::Statement, Error>> + 'e + Send>> where
'q: 'e,
'c: 'e,
[src]
self,
query: &'q str
) -> Pin<Box<dyn Future<Output = Result<<Self::Database as HasStatement<'q>>::Statement, Error>> + 'e + Send>> where
'q: 'e,
'c: 'e,
Auto Trait Implementations
impl<DB> !RefUnwindSafe for Pool<DB>
impl<DB> Send for Pool<DB> where
<DB as Database>::Connection: Send,
<<DB as Database>::Connection as Connection>::Options: Send + Sync,
<DB as Database>::Connection: Send,
<<DB as Database>::Connection as Connection>::Options: Send + Sync,
impl<DB> Sync for Pool<DB> where
<DB as Database>::Connection: Send,
<<DB as Database>::Connection as Connection>::Options: Send + Sync,
<DB as Database>::Connection: Send,
<<DB as Database>::Connection as Connection>::Options: Send + Sync,
impl<DB> Unpin for Pool<DB>
impl<DB> !UnwindSafe for Pool<DB>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,