DatabaseProvider

Trait DatabaseProvider 

Source
pub trait DatabaseProvider:
    Send
    + Sync
    + 'static {
    // Required methods
    fn list_tables<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<TableInfo>, DatabaseError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_table_schema<'life0, 'life1, 'async_trait>(
        &'life0 self,
        table: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<TableSchema, DatabaseError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_rows<'life0, 'life1, 'async_trait>(
        &'life0 self,
        table: &'life1 str,
        query: RowQuery,
    ) -> Pin<Box<dyn Future<Output = Result<RowsResponse, DatabaseError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn count_rows<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        table: &'life1 str,
        query: &'life2 RowQuery,
    ) -> Pin<Box<dyn Future<Output = Result<CountResponse, DatabaseError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn execute_query<'life0, 'life1, 'async_trait>(
        &'life0 self,
        sql: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<QueryResult, DatabaseError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Database provider trait for schema discovery and data access

Implementations of this trait provide database-specific logic for discovering schema information and fetching data.

Required Methods§

Source

fn list_tables<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<TableInfo>, DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List all table names in the database

§Returns

A vector of table information, optionally including row counts

Source

fn get_table_schema<'life0, 'life1, 'async_trait>( &'life0 self, table: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<TableSchema, DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get schema information for a specific table

§Arguments
  • table - Name of the table
§Returns

Complete schema information including columns, keys, and indexes

Source

fn get_rows<'life0, 'life1, 'async_trait>( &'life0 self, table: &'life1 str, query: RowQuery, ) -> Pin<Box<dyn Future<Output = Result<RowsResponse, DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetch rows with pagination, sorting, and filtering

§Arguments
  • table - Name of the table
  • query - Query parameters (pagination, sorting, filters)
§Returns

Paginated rows with metadata

Source

fn count_rows<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, table: &'life1 str, query: &'life2 RowQuery, ) -> Pin<Box<dyn Future<Output = Result<CountResponse, DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get total row count for a table (with optional filters)

§Arguments
  • table - Name of the table
  • query - Query parameters (filters)
§Returns

Total row count

Source

fn execute_query<'life0, 'life1, 'async_trait>( &'life0 self, sql: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<QueryResult, DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute a raw SQL query

§Security Warning

This allows executing any SQL statement including INSERT, UPDATE, DELETE. Only use in development environments!

§Arguments
  • sql - SQL query to execute
§Returns

Query results with execution metadata

Implementors§