Struct pgdb::PostgresClient
source · 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
.
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