pub struct PostgresResource {
pub database: String,
pub host: String,
pub port: u16,
pub user: String,
pub password: String,
/* private fields */
}Expand description
PostgreSQL resource manager
Fields§
§database: StringName of the isolated database
host: StringHost
port: u16Port
user: StringUser
password: StringPassword
Implementations§
Source§impl PostgresResource
impl PostgresResource
Sourcepub async fn connect_existing(admin_url: &str, database: &str) -> Result<Self>
pub async fn connect_existing(admin_url: &str, database: &str) -> Result<Self>
Connect to an existing PostgreSQL database (for inspection, does not drop on cleanup)
Sourcepub async fn new(admin_url: &str, database: &str) -> Result<Self>
pub async fn new(admin_url: &str, database: &str) -> Result<Self>
Create a new PostgreSQL resource with an isolated database
Sourcepub fn connection_string(&self) -> String
pub fn connection_string(&self) -> String
Get the connection string for the isolated database
Sourcepub async fn count(&self, query: &str) -> Result<i64>
pub async fn count(&self, query: &str) -> Result<i64>
Execute a count query and return the result
Sourcepub async fn query<T>(&self, query: &str) -> Result<Vec<T>>
pub async fn query<T>(&self, query: &str) -> Result<Vec<T>>
Execute a query and return typed results
Sourcepub async fn list_tables(&self) -> Result<Vec<String>>
pub async fn list_tables(&self) -> Result<Vec<String>>
List all tables in the database
Sourcepub async fn get_sample_data(
&self,
table: &str,
limit: usize,
) -> Result<Vec<Vec<String>>>
pub async fn get_sample_data( &self, table: &str, limit: usize, ) -> Result<Vec<Vec<String>>>
Get sample data from a table (first N rows)
Trait Implementations§
Source§impl Drop for PostgresResource
impl Drop for PostgresResource
Auto Trait Implementations§
impl !RefUnwindSafe for PostgresResource
impl !UnwindSafe for PostgresResource
impl Freeze for PostgresResource
impl Send for PostgresResource
impl Sync for PostgresResource
impl Unpin for PostgresResource
impl UnsafeUnpin for PostgresResource
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> 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 moreCreates a shared type from an unshared type.