pub mod core;
pub mod postgres;
pub use core::*;
pub use postgres::PostgresBackend;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum DatabaseBackendType {
PostgreSQL,
MySQL,
SQLite,
}
impl std::fmt::Display for DatabaseBackendType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
DatabaseBackendType::PostgreSQL => write!(f, "postgresql"),
DatabaseBackendType::MySQL => write!(f, "mysql"),
DatabaseBackendType::SQLite => write!(f, "sqlite"),
}
}
}
impl std::str::FromStr for DatabaseBackendType {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"postgresql" | "postgres" => Ok(DatabaseBackendType::PostgreSQL),
"mysql" => Ok(DatabaseBackendType::MySQL),
"sqlite" => Ok(DatabaseBackendType::SQLite),
_ => Err(format!("Unsupported database backend: {}", s)),
}
}
}