pub enum Backend {
Mysql(MysqlBackend),
Postgres(PostgresBackend),
Sqlite(SqliteBackend),
}Expand description
Concrete database backend — dispatches to the active variant.
Only one instance exists for the program lifetime, so the size difference between variants is irrelevant.
Variants§
Mysql(MysqlBackend)
MySQL/MariaDB via sqlx.
Postgres(PostgresBackend)
PostgreSQL via sqlx.
Sqlite(SqliteBackend)
SQLite via sqlx.
Implementations§
Source§impl Backend
impl Backend
Sourcepub async fn tool_list_databases(&self) -> Result<String, AppError>
pub async fn tool_list_databases(&self) -> Result<String, AppError>
Sourcepub async fn tool_get_table_schema(
&self,
database_name: &str,
table_name: &str,
) -> Result<String, AppError>
pub async fn tool_get_table_schema( &self, database_name: &str, table_name: &str, ) -> Result<String, AppError>
Sourcepub async fn tool_get_table_schema_with_relations(
&self,
database_name: &str,
table_name: &str,
) -> Result<String, AppError>
pub async fn tool_get_table_schema_with_relations( &self, database_name: &str, table_name: &str, ) -> Result<String, AppError>
Sourcepub async fn tool_execute_sql(
&self,
sql_query: &str,
database_name: &str,
) -> Result<String, AppError>
pub async fn tool_execute_sql( &self, sql_query: &str, database_name: &str, ) -> Result<String, AppError>
Executes a SQL query and returns results as a JSON string.
Includes read-only validation as defence-in-depth. The read_query
tool handler also validates, but this ensures safety even when
calling tool_execute_sql directly (e.g. from integration tests).
§Errors
Returns AppError if the query is blocked by read-only mode
or the backend query fails.
Trait Implementations§
Source§impl DatabaseBackend for Backend
impl DatabaseBackend for Backend
Source§async fn list_databases(&self) -> Result<Vec<String>, AppError>
async fn list_databases(&self) -> Result<Vec<String>, AppError>
Lists all accessible databases.
Source§async fn list_tables(&self, database: &str) -> Result<Vec<String>, AppError>
async fn list_tables(&self, database: &str) -> Result<Vec<String>, AppError>
Lists all tables in a database.
Source§async fn get_table_schema(
&self,
database: &str,
table: &str,
) -> Result<Value, AppError>
async fn get_table_schema( &self, database: &str, table: &str, ) -> Result<Value, AppError>
Returns column definitions for a table.
Source§async fn get_table_schema_with_relations(
&self,
database: &str,
table: &str,
) -> Result<Value, AppError>
async fn get_table_schema_with_relations( &self, database: &str, table: &str, ) -> Result<Value, AppError>
Returns column definitions with foreign key relationships.
Source§async fn execute_query(
&self,
sql: &str,
database: Option<&str>,
) -> Result<Value, AppError>
async fn execute_query( &self, sql: &str, database: Option<&str>, ) -> Result<Value, AppError>
Executes a SQL query and returns rows as a JSON array.
Auto Trait Implementations§
impl Freeze for Backend
impl !RefUnwindSafe for Backend
impl Send for Backend
impl Sync for Backend
impl Unpin for Backend
impl UnsafeUnpin for Backend
impl !UnwindSafe for Backend
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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