Struct diesel_oci::OciConnection
source · pub struct OciConnection { /* private fields */ }
Expand description
Connections for the Oracle backend. The following connection url schema is supported:
oracle://user:password@host:[port]/database
where:
user
is your usernamepassword
is the corresponding passwordhost
is the hostname/ip address of the database serverport
is an optional port numberdatabase
is your database name
Supported loading model implementations
- [
DefaultLoadingMode
]
As OciConnection
only supports a single loading mode implementation
it is not required to explicitly specify a loading mode
when calling RunQueryDsl::load_iter()
or LoadConnection::load
DefaultLoadingMode
OciConnection
only supports a single loading mode, which internally loads
all values at once.
use diesel::connection::DefaultLoadingMode;
{ // scope to restrict the lifetime of the iterator
let iter1 = users::table.load_iter::<(i32, String), DefaultLoadingMode>(connection)?;
for r in iter1 {
let (id, name) = r?;
println!("Id: {} Name: {}", id, name);
}
}
// works without specifying the loading mode
let iter2 = users::table.load_iter::<(i32, String), _>(connection)?;
for r in iter2 {
let (id, name) = r?;
println!("Id: {} Name: {}", id, name);
}
This mode does support creating multiple iterators using the same connection.
use diesel::connection::DefaultLoadingMode;
let iter1 = users::table.load_iter::<(i32, String), DefaultLoadingMode>(connection)?;
let iter2 = users::table.load_iter::<(i32, String), DefaultLoadingMode>(connection)?;
for r in iter1 {
let (id, name) = r?;
println!("Id: {} Name: {}", id, name);
}
for r in iter2 {
let (id, name) = r?;
println!("Id: {} Name: {}", id, name);
}
Trait Implementations§
source§impl Connection for OciConnection
impl Connection for OciConnection
source§fn establish(database_url: &str) -> ConnectionResult<Self>
fn establish(database_url: &str) -> ConnectionResult<Self>
Establishes a new connection to the database at the given URL. The URL should be a valid connection string for a given backend. See the documentation for the specific backend for specifics.
§type TransactionManager = OCITransactionManager
type TransactionManager = OCITransactionManager
The transaction manager implementation used by this connection
source§fn transaction_state(
&mut self
) -> &mut <Self::TransactionManager as TransactionManager<Self>>::TransactionStateData
fn transaction_state( &mut self ) -> &mut <Self::TransactionManager as TransactionManager<Self>>::TransactionStateData
Get access to the current transaction state of this connection Read more
source§fn begin_test_transaction(&mut self) -> QueryResult<()>
fn begin_test_transaction(&mut self) -> QueryResult<()>
Creates a transaction that will never be committed. This is useful for
tests. Panics if called while inside of a transaction or
if called with a connection containing a broken transaction
source§fn transaction<T, E, F>(&mut self, f: F) -> Result<T, E>where
F: FnOnce(&mut Self) -> Result<T, E>,
E: From<Error>,
fn transaction<T, E, F>(&mut self, f: F) -> Result<T, E>where F: FnOnce(&mut Self) -> Result<T, E>, E: From<Error>,
Executes the given function inside of a database transaction Read more
source§fn test_transaction<T, E, F>(&mut self, f: F) -> Twhere
F: FnOnce(&mut Self) -> Result<T, E>,
E: Debug,
fn test_transaction<T, E, F>(&mut self, f: F) -> Twhere F: FnOnce(&mut Self) -> Result<T, E>, E: Debug,
Executes the given function inside a transaction, but does not commit
it. Panics if the given function returns an error. Read more
source§fn execute_returning_count<T>(&mut self, source: &T) -> Result<usize, Error>where
T: QueryFragment<Self::Backend, NotSpecialized> + QueryId,
fn execute_returning_count<T>(&mut self, source: &T) -> Result<usize, Error>where T: QueryFragment<Self::Backend, NotSpecialized> + QueryId,
Execute a single SQL statements given by a query and return
number of affected rows
source§impl Drop for OciConnection
impl Drop for OciConnection
source§impl<V, T, QId, Op, const STATIC_QUERY_ID: bool> ExecuteDsl<OciConnection, <OciConnection as Connection>::Backend> for (Yes, InsertStatement<T, BatchInsert<Vec<ValuesClause<V, T>>, T, QId, STATIC_QUERY_ID>, Op>)where
T: Table + Copy + QueryId + 'static,
T::FromClause: QueryFragment<Oracle>,
Op: Copy + QueryId + QueryFragment<Oracle>,
V: InsertValues<T, Oracle> + CanInsertInSingleQuery<Oracle> + QueryId,
impl<V, T, QId, Op, const STATIC_QUERY_ID: bool> ExecuteDsl<OciConnection, <OciConnection as Connection>::Backend> for (Yes, InsertStatement<T, BatchInsert<Vec<ValuesClause<V, T>>, T, QId, STATIC_QUERY_ID>, Op>)where T: Table + Copy + QueryId + 'static, T::FromClause: QueryFragment<Oracle>, Op: Copy + QueryId + QueryFragment<Oracle>, V: InsertValues<T, Oracle> + CanInsertInSingleQuery<Oracle> + QueryId,
source§fn execute((Yes, query): Self, conn: &mut OciConnection) -> QueryResult<usize>
fn execute((Yes, query): Self, conn: &mut OciConnection) -> QueryResult<usize>
Execute this command
source§impl<V, T, QId, Op, const STATIC_QUERY_ID: bool> ExecuteDsl<OciConnection, Oracle> for (No, InsertStatement<T, BatchInsert<V, T, QId, STATIC_QUERY_ID>, Op>)where
T: Table + QueryId + 'static,
T::FromClause: QueryFragment<Oracle>,
Op: QueryFragment<Oracle> + QueryId,
OracleBatchInsertWrapper<V, T, QId, STATIC_QUERY_ID>: QueryFragment<Oracle> + QueryId + CanInsertInSingleQuery<Oracle>,
impl<V, T, QId, Op, const STATIC_QUERY_ID: bool> ExecuteDsl<OciConnection, Oracle> for (No, InsertStatement<T, BatchInsert<V, T, QId, STATIC_QUERY_ID>, Op>)where T: Table + QueryId + 'static, T::FromClause: QueryFragment<Oracle>, Op: QueryFragment<Oracle> + QueryId, OracleBatchInsertWrapper<V, T, QId, STATIC_QUERY_ID>: QueryFragment<Oracle> + QueryId + CanInsertInSingleQuery<Oracle>,
source§fn execute((No, query): Self, conn: &mut OciConnection) -> QueryResult<usize>
fn execute((No, query): Self, conn: &mut OciConnection) -> QueryResult<usize>
Execute this command
source§impl<V, T, QId, Op, O, const STATIC_QUERY_ID: bool> ExecuteDsl<OciConnection, Oracle> for InsertStatement<T, BatchInsert<Vec<ValuesClause<V, T>>, T, QId, STATIC_QUERY_ID>, Op>where
T: QuerySource,
V: ContainsDefaultableValue<Out = O>,
O: Default,
(O, Self): ExecuteDsl<OciConnection, Oracle>,
impl<V, T, QId, Op, O, const STATIC_QUERY_ID: bool> ExecuteDsl<OciConnection, Oracle> for InsertStatement<T, BatchInsert<Vec<ValuesClause<V, T>>, T, QId, STATIC_QUERY_ID>, Op>where T: QuerySource, V: ContainsDefaultableValue<Out = O>, O: Default, (O, Self): ExecuteDsl<OciConnection, Oracle>,
source§fn execute(query: Self, conn: &mut OciConnection) -> QueryResult<usize>
fn execute(query: Self, conn: &mut OciConnection) -> QueryResult<usize>
Execute this command
source§impl LoadConnection<DefaultLoadingMode> for OciConnection
impl LoadConnection<DefaultLoadingMode> for OciConnection
§type Cursor<'conn, 'query> = RowIter
type Cursor<'conn, 'query> = RowIter
The cursor type returned by
LoadConnection::load
Read more§type Row<'conn, 'query> = OciRow
type Row<'conn, 'query> = OciRow
The row type used as
Iterator::Item
for the iterator implementation
of LoadConnection::Cursor
source§fn load<'conn, 'query, T>(&'conn mut self, source: T) -> QueryResult<RowIter>where
T: AsQuery,
T::Query: QueryFragment<Self::Backend> + QueryId + 'query,
Self::Backend: QueryMetadata<T::SqlType>,
fn load<'conn, 'query, T>(&'conn mut self, source: T) -> QueryResult<RowIter>where T: AsQuery, T::Query: QueryFragment<Self::Backend> + QueryId + 'query, Self::Backend: QueryMetadata<T::SqlType>,
Executes a given query and returns any requested values Read more
source§impl MigrationConnection for OciConnection
impl MigrationConnection for OciConnection
source§impl MultiConnectionHelper for OciConnection
impl MultiConnectionHelper for OciConnection
source§fn to_any<'a>(
lookup: &mut <Self::Backend as TypeMetadata>::MetadataLookup
) -> &mut (dyn Any + 'a)
fn to_any<'a>( lookup: &mut <Self::Backend as TypeMetadata>::MetadataLookup ) -> &mut (dyn Any + 'a)
Convert the lookup type to any
source§fn from_any(
lookup: &mut dyn Any
) -> Option<&mut <Self::Backend as TypeMetadata>::MetadataLookup>
fn from_any( lookup: &mut dyn Any ) -> Option<&mut <Self::Backend as TypeMetadata>::MetadataLookup>
Get the lookup type from any
source§impl R2D2Connection for OciConnection
impl R2D2Connection for OciConnection
source§impl SimpleConnection for OciConnection
impl SimpleConnection for OciConnection
source§fn batch_execute(&mut self, query: &str) -> QueryResult<()>
fn batch_execute(&mut self, query: &str) -> QueryResult<()>
Execute multiple SQL statements within the same string. Read more
source§impl<'query, Changes, Output> UpdateAndFetchResults<Changes, Output> for OciConnectionwhere
Changes: Copy + Identifiable + AsChangeset<Target = <Changes as HasTable>::Table> + IntoUpdateTarget,
Changes::Table: FindDsl<Changes::Id>,
Update<Changes, Changes>: ExecuteDsl<OciConnection> + AsQuery,
Find<Changes::Table, Changes::Id>: LoadQuery<'query, OciConnection, Output>,
impl<'query, Changes, Output> UpdateAndFetchResults<Changes, Output> for OciConnectionwhere Changes: Copy + Identifiable + AsChangeset<Target = <Changes as HasTable>::Table> + IntoUpdateTarget, Changes::Table: FindDsl<Changes::Id>, Update<Changes, Changes>: ExecuteDsl<OciConnection> + AsQuery, Find<Changes::Table, Changes::Id>: LoadQuery<'query, OciConnection, Output>,
source§fn update_and_fetch(&mut self, changeset: Changes) -> QueryResult<Output>
fn update_and_fetch(&mut self, changeset: Changes) -> QueryResult<Output>
See the traits documentation.
impl ConnectionSealed for OciConnection
impl Send for OciConnection
Auto Trait Implementations§
impl RefUnwindSafe for OciConnection
impl Sync for OciConnection
impl Unpin for OciConnection
impl UnwindSafe for OciConnection
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<C> BoxableConnection<<C as Connection>::Backend> for Cwhere
C: Connection + Any,
impl<C> BoxableConnection<<C as Connection>::Backend> for Cwhere C: Connection + Any,
source§impl<T> IntoSql for T
impl<T> IntoSql for T
source§fn into_sql<T>(self) -> Self::Expressionwhere
Self: AsExpression<T> + Sized,
T: SqlType + TypedExpressionType,
fn into_sql<T>(self) -> Self::Expressionwhere Self: AsExpression<T> + Sized, T: SqlType + TypedExpressionType,
Convert
self
to an expression for Diesel’s query builder. Read moresource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
&'a Self: AsExpression<T>,
T: SqlType + TypedExpressionType,
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,
Convert
&self
to an expression for Diesel’s query builder. Read more