datafusion_table_providers/sql/db_connection_pool/
mod.rs1use async_trait::async_trait;
2use dbconnection::DbConnection;
3use std::sync::Arc;
4
5pub mod dbconnection;
6#[cfg(feature = "duckdb")]
7pub mod duckdbpool;
8#[cfg(feature = "mysql")]
9pub mod mysqlpool;
10#[cfg(feature = "odbc")]
11pub mod odbcpool;
12#[cfg(feature = "postgres")]
13pub mod postgrespool;
14pub mod runtime;
15#[cfg(feature = "sqlite")]
16pub mod sqlitepool;
17
18pub type Error = Box<dyn std::error::Error + Send + Sync>;
19type Result<T, E = Error> = std::result::Result<T, E>;
20
21#[derive(Clone, Debug, PartialEq, Eq)]
23pub enum JoinPushDown {
24 Disallow,
26 AllowedFor(String),
30}
31
32#[async_trait]
33pub trait DbConnectionPool<T, P: 'static> {
34 async fn connect(&self) -> Result<Box<dyn DbConnection<T, P>>>;
35
36 fn join_push_down(&self) -> JoinPushDown;
37}
38
39#[derive(Default, Debug, Clone, Copy, PartialEq, Eq)]
40pub enum Mode {
41 #[default]
42 Memory,
43 File,
44}
45
46impl From<&str> for Mode {
47 fn from(m: &str) -> Self {
48 match m {
49 "file" => Mode::File,
50 "memory" => Mode::Memory,
51 _ => Mode::default(),
52 }
53 }
54}
55
56#[derive(Debug, Clone, PartialEq, Eq, Hash)]
58pub enum DbInstanceKey {
59 File(Arc<str>),
61 Memory,
63}
64
65impl DbInstanceKey {
66 pub fn memory() -> Self {
67 DbInstanceKey::Memory
68 }
69
70 pub fn file(path: Arc<str>) -> Self {
71 DbInstanceKey::File(path)
72 }
73}