datafusion_table_providers/sql/db_connection_pool/
mod.rsuse async_trait::async_trait;
use dbconnection::DbConnection;
use std::sync::Arc;
pub mod dbconnection;
#[cfg(feature = "duckdb")]
pub mod duckdbpool;
#[cfg(feature = "mysql")]
pub mod mysqlpool;
#[cfg(feature = "postgres")]
pub mod postgrespool;
#[cfg(feature = "sqlite")]
pub mod sqlitepool;
pub type Error = Box<dyn std::error::Error + Send + Sync>;
type Result<T, E = Error> = std::result::Result<T, E>;
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum JoinPushDown {
Disallow,
AllowedFor(String),
}
#[async_trait]
pub trait DbConnectionPool<T, P: 'static> {
async fn connect(&self) -> Result<Box<dyn DbConnection<T, P>>>;
fn join_push_down(&self) -> JoinPushDown;
}
#[derive(Default, Clone, Copy, PartialEq, Eq)]
pub enum Mode {
#[default]
Memory,
File,
}
impl From<&str> for Mode {
fn from(m: &str) -> Self {
match m {
"file" => Mode::File,
"memory" => Mode::Memory,
_ => Mode::default(),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum DbInstanceKey {
File(Arc<str>),
Memory,
}
impl DbInstanceKey {
pub fn memory() -> Self {
DbInstanceKey::Memory
}
pub fn file(path: Arc<str>) -> Self {
DbInstanceKey::File(path)
}
}