Enum autopulse::db::conn::AnyConnection
source · pub enum AnyConnection {
Postgresql(PgConnection),
Sqlite(SqliteConnection),
}
Expand description
Represents a connection to either a PostgreSQL or SQLite database.
Variants§
Postgresql(PgConnection)
A connection to a PostgreSQL database.
This is used when the database_url
is a PostgreSQL URL.
§Example
postgres://user:password@localhost:5432/database
Sqlite(SqliteConnection)
A connection to a SQLite database.
This is used when the database_url
is a SQLite URL.
Note: The directory where the database is stored will also be populated with a WAL file and a journal file.
§Example
# Relative path
sqlite://database.db
sqlite://data/database.db
# Absolute path
sqlite:///data/database.db
# In-memory database
sqlite://:memory: # In-memory database
Implementations§
source§impl AnyConnection
impl AnyConnection
pub fn pre_init(database_url: &str) -> Result<()>
pub fn init(&mut self) -> Result<()>
pub fn migrate(&mut self) -> Result<()>
pub fn save_changes(&mut self, ev: &mut ScanEvent) -> Result<ScanEvent>
pub fn insert_and_return(&mut self, ev: &NewScanEvent) -> Result<ScanEvent>
Trait Implementations§
source§impl Connection for MultiConnection
impl Connection for MultiConnection
source§type Backend = MultiBackend
type Backend = MultiBackend
The backend this type connects to
source§fn establish(database_url: &str) -> ConnectionResult<Self>
fn establish(database_url: &str) -> ConnectionResult<Self>
Establishes a new connection to the database Read more
source§fn set_instrumentation(&mut self, instrumentation: impl Instrumentation)
fn set_instrumentation(&mut self, instrumentation: impl Instrumentation)
Set a specific [
Instrumentation
] implementation for this connectionsource§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
§fn transaction<T, E, F>(&mut self, f: F) -> Result<T, E>
fn transaction<T, E, F>(&mut self, f: F) -> Result<T, E>
Executes the given function inside of a database transaction Read more
source§impl LoadConnection for MultiConnection
impl LoadConnection for MultiConnection
source§type Cursor<'conn, 'query> = MultiCursor<'conn, 'query>
type Cursor<'conn, 'query> = MultiCursor<'conn, 'query>
The cursor type returned by [
LoadConnection::load
] Read moresource§type Row<'conn, 'query> = MultiRow<'conn, 'query>
type Row<'conn, 'query> = MultiRow<'conn, 'query>
The row type used as
Iterator::Item
for the iterator implementation
of [LoadConnection::Cursor
]source§impl MigrationConnection for MultiConnection
impl MigrationConnection for MultiConnection
source§impl R2D2Connection for MultiConnection
impl R2D2Connection for MultiConnection
source§impl SimpleConnection for MultiConnection
impl SimpleConnection for MultiConnection
source§impl TransactionManager<AnyConnection> for MultiConnection
impl TransactionManager<AnyConnection> for MultiConnection
source§type TransactionStateData = AnyConnection
type TransactionStateData = AnyConnection
Data stored as part of the connection implementation
to track the current transaction state of a connection
source§fn begin_transaction(conn: &mut MultiConnection) -> QueryResult<()>
fn begin_transaction(conn: &mut MultiConnection) -> QueryResult<()>
Begin a new transaction or savepoint Read more
source§fn rollback_transaction(conn: &mut MultiConnection) -> QueryResult<()>
fn rollback_transaction(conn: &mut MultiConnection) -> QueryResult<()>
Rollback the inner-most transaction or savepoint Read more
source§fn commit_transaction(conn: &mut MultiConnection) -> QueryResult<()>
fn commit_transaction(conn: &mut MultiConnection) -> QueryResult<()>
Commit the inner-most transaction or savepoint Read more
impl ConnectionSealed for MultiConnection
Auto Trait Implementations§
impl Freeze for AnyConnection
impl !RefUnwindSafe for AnyConnection
impl Send for AnyConnection
impl !Sync for AnyConnection
impl Unpin for AnyConnection
impl !UnwindSafe for AnyConnection
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoSql for T
impl<T> IntoSql for T
§impl<'b, C, DB> MigrationHarness<DB> for Cwhere
DB: Backend,
C: Connection<Backend = DB> + MigrationConnection + 'static,
<<table as SelectDsl<version>>::Output as OrderDsl<Desc<version>>>::Output: LoadQuery<'b, C, MigrationVersion<'static>>,
InsertStatement<table, <Grouped<Eq<version, <MigrationVersion<'static> as AsExpression<<version as Expression>::SqlType>>::Expression>> as Insertable<table>>::Values>: for<'a> QueryFragment<DB> + for<'a> ExecuteDsl<C, DB>,
DeleteStatement<<<table as FindDsl<MigrationVersion<'static>>>::Output as HasTable>::Table, <<table as FindDsl<MigrationVersion<'static>>>::Output as IntoUpdateTarget>::WhereClause>: ExecuteDsl<C>,
str: ToSql<Text, DB>,
impl<'b, C, DB> MigrationHarness<DB> for Cwhere
DB: Backend,
C: Connection<Backend = DB> + MigrationConnection + 'static,
<<table as SelectDsl<version>>::Output as OrderDsl<Desc<version>>>::Output: LoadQuery<'b, C, MigrationVersion<'static>>,
InsertStatement<table, <Grouped<Eq<version, <MigrationVersion<'static> as AsExpression<<version as Expression>::SqlType>>::Expression>> as Insertable<table>>::Values>: for<'a> QueryFragment<DB> + for<'a> ExecuteDsl<C, DB>,
DeleteStatement<<<table as FindDsl<MigrationVersion<'static>>>::Output as HasTable>::Table, <<table as FindDsl<MigrationVersion<'static>>>::Output as IntoUpdateTarget>::WhereClause>: ExecuteDsl<C>,
str: ToSql<Text, DB>,
§fn run_migration(
&mut self,
migration: &dyn Migration<DB>,
) -> Result<MigrationVersion<'static>, Box<dyn Error + Sync + Send>>
fn run_migration( &mut self, migration: &dyn Migration<DB>, ) -> Result<MigrationVersion<'static>, Box<dyn Error + Sync + Send>>
Apply a single migration Read more
§fn revert_migration(
&mut self,
migration: &dyn Migration<DB>,
) -> Result<MigrationVersion<'static>, Box<dyn Error + Sync + Send>>
fn revert_migration( &mut self, migration: &dyn Migration<DB>, ) -> Result<MigrationVersion<'static>, Box<dyn Error + Sync + Send>>
Revert a single migration Read more
§fn applied_migrations(
&mut self,
) -> Result<Vec<MigrationVersion<'static>>, Box<dyn Error + Sync + Send>>
fn applied_migrations( &mut self, ) -> Result<Vec<MigrationVersion<'static>>, Box<dyn Error + Sync + Send>>
Get a list of already applied migration versions
§fn has_pending_migration<S>(
&mut self,
source: S,
) -> Result<bool, Box<dyn Error + Sync + Send>>where
S: MigrationSource<DB>,
fn has_pending_migration<S>(
&mut self,
source: S,
) -> Result<bool, Box<dyn Error + Sync + Send>>where
S: MigrationSource<DB>,
Checks if the database represented by the current harness has unapplied migrations
§fn run_pending_migrations<S>(
&mut self,
source: S,
) -> Result<Vec<MigrationVersion<'_>>, Box<dyn Error + Sync + Send>>where
S: MigrationSource<DB>,
fn run_pending_migrations<S>(
&mut self,
source: S,
) -> Result<Vec<MigrationVersion<'_>>, Box<dyn Error + Sync + Send>>where
S: MigrationSource<DB>,
Execute all unapplied migrations for a given migration source
§fn run_next_migration<S>(
&mut self,
source: S,
) -> Result<MigrationVersion<'_>, Box<dyn Error + Sync + Send>>where
S: MigrationSource<DB>,
fn run_next_migration<S>(
&mut self,
source: S,
) -> Result<MigrationVersion<'_>, Box<dyn Error + Sync + Send>>where
S: MigrationSource<DB>,
Execute the next migration from the given migration source
§fn revert_all_migrations<S>(
&mut self,
source: S,
) -> Result<Vec<MigrationVersion<'_>>, Box<dyn Error + Sync + Send>>where
S: MigrationSource<DB>,
fn revert_all_migrations<S>(
&mut self,
source: S,
) -> Result<Vec<MigrationVersion<'_>>, Box<dyn Error + Sync + Send>>where
S: MigrationSource<DB>,
Revert all applied migrations from a given migration source