pub mod mysql; pub mod postgres; pub mod sqlite; pub use mysql::MySqlPool; pub use postgres::PostgresPool; pub use sqlite::SqlitePool; use async_trait::async_trait; use database_tree::{Child, Database, Table}; pub const RECORDS_LIMIT_PER_PAGE: u8 = 200; #[async_trait] pub trait Pool: Send + Sync { async fn execute(&self, query: &String) -> anyhow::Result; async fn get_databases(&self) -> anyhow::Result>; async fn get_tables(&self, database: String) -> anyhow::Result>; async fn get_records( &self, database: &Database, table: &Table, page: u16, filter: Option, ) -> anyhow::Result<(Vec, Vec>)>; async fn get_columns( &self, database: &Database, table: &Table, ) -> anyhow::Result>>; async fn get_constraints( &self, database: &Database, table: &Table, ) -> anyhow::Result>>; async fn get_foreign_keys( &self, database: &Database, table: &Table, ) -> anyhow::Result>>; async fn get_indexes( &self, database: &Database, table: &Table, ) -> anyhow::Result>>; async fn close(&self); } pub enum ExecuteResult { Read { headers: Vec, rows: Vec>, database: Database, table: Table, }, Write { updated_rows: u64, }, } pub trait TableRow: std::marker::Send { fn fields(&self) -> Vec; fn columns(&self) -> Vec; } #[macro_export] macro_rules! get_or_null { ($value:expr) => { $value.map_or("NULL".to_string(), |v| v.to_string()) }; }