pub struct PostgresClient<'a> { /* private fields */ }Expand description
A virtual client for a running postgres.
Contains credentials and enough information to connect to its parent instance.
Implementations§
Source§impl<'a> PostgresClient<'a>
impl<'a> PostgresClient<'a>
Sourcepub fn psql(&self, database: &str) -> Command
pub fn psql(&self, database: &str) -> Command
Runs a psql command against the database.
Creates a command that runs psql -h (host) -p (port) -U (username) -d (database) with
PGPASSWORD set.
Sourcepub fn load_sql<P: AsRef<Path>>(
&self,
database: &str,
filename: P,
) -> Result<(), Error>
pub fn load_sql<P: AsRef<Path>>( &self, database: &str, filename: P, ) -> Result<(), Error>
Runs the given SQL commands from an input file via psql.
Sourcepub fn run_sql(&self, database: &str, sql: &str) -> Result<(), Error>
pub fn run_sql(&self, database: &str, sql: &str) -> Result<(), Error>
Runs the given SQL command through psql.
Sourcepub fn create_database(&self, database: &str, owner: &str) -> Result<(), Error>
pub fn create_database(&self, database: &str, owner: &str) -> Result<(), Error>
Creates a new database with the given owner.
This typically requires superuser credentials, see Postgres::as_superuser.
Sourcepub fn create_user(&self, username: &str, password: &str) -> Result<(), Error>
pub fn create_user(&self, username: &str, password: &str) -> Result<(), Error>
Creates a new user on the system that is allowed to login.
This typically requires superuser credentials, see Postgres::as_superuser.
Sourcepub fn client_url(&self) -> &Url
pub fn client_url(&self) -> &Url
Returns the client URL for this client.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for PostgresClient<'a>
impl<'a> RefUnwindSafe for PostgresClient<'a>
impl<'a> Send for PostgresClient<'a>
impl<'a> Sync for PostgresClient<'a>
impl<'a> Unpin for PostgresClient<'a>
impl<'a> UnwindSafe for PostgresClient<'a>
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> 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