pub enum DatabaseConnection {
PostgreSQL(PostgresConnection),
DuckDB(DuckDBConnection),
Redis(RedisConnection),
Unsupported(String),
}Expand description
Database connection enum that wraps different database drivers
Variants§
Implementations§
Source§impl DatabaseConnection
impl DatabaseConnection
Sourcepub async fn new(
connection_string: &str,
db_type: DatabaseType,
) -> DatabaseResult<Self>
pub async fn new( connection_string: &str, db_type: DatabaseType, ) -> DatabaseResult<Self>
Create a new connection based on connection string and database type
Sourcepub async fn execute(&self, query: &str) -> DatabaseResult<Recordset>
pub async fn execute(&self, query: &str) -> DatabaseResult<Recordset>
Execute a query and return results
Sourcepub async fn execute_command(&self, command: &str) -> DatabaseResult<u64>
pub async fn execute_command(&self, command: &str) -> DatabaseResult<u64>
Execute a command (INSERT, UPDATE, DELETE) and return rows affected
Sourcepub async fn close(&mut self) -> DatabaseResult<()>
pub async fn close(&mut self) -> DatabaseResult<()>
Close the connection
Sourcepub async fn is_connected(&self) -> bool
pub async fn is_connected(&self) -> bool
Check if connection is alive
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for DatabaseConnection
impl !RefUnwindSafe for DatabaseConnection
impl Send for DatabaseConnection
impl Sync for DatabaseConnection
impl Unpin for DatabaseConnection
impl !UnwindSafe for DatabaseConnection
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> 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