pub struct PostgresBackend {
pub read_only: bool,
/* private fields */
}Expand description
PostgreSQL database backend.
All connection pools — including the default — live in a single concurrent cache keyed by database name. No external mutex required.
Fields§
§read_only: boolImplementations§
Source§impl PostgresBackend
impl PostgresBackend
Sourcepub async fn new(config: &DatabaseConfig) -> Result<Self, AppError>
pub async fn new(config: &DatabaseConfig) -> Result<Self, AppError>
Creates a new PostgreSQL backend from configuration.
Stores a clone of the configuration for constructing connection options for non-default databases at runtime. The initial pool is placed into the shared cache keyed by the configured database name.
§Errors
Returns AppError::Connection if the connection fails.
Trait Implementations§
Source§impl Clone for PostgresBackend
impl Clone for PostgresBackend
Source§fn clone(&self) -> PostgresBackend
fn clone(&self) -> PostgresBackend
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl DatabaseBackend for PostgresBackend
impl DatabaseBackend for PostgresBackend
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 PostgresBackend
impl !RefUnwindSafe for PostgresBackend
impl Send for PostgresBackend
impl Sync for PostgresBackend
impl Unpin for PostgresBackend
impl UnsafeUnpin for PostgresBackend
impl !UnwindSafe for PostgresBackend
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