pub fn destroy(uri: &str) -> Result<()> {
        let params = try!(uri.into_connect_params().map_err(|_| ErrorKind::UriParse));
        let old_db = try!(params.database().ok_or_else(|| {
            ErrorKind::Arg(format!("No database specified to destroy in {}.", uri))
        }));
        let pg_params = param_into_builder(&params).database("postgres").build(
            params
                .host()
                .clone(),
        );
        let conn = Connection::connect(pg_params, postgres::TlsMode::None)?;
        let disco_query = format!(
            "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM \
                                   pg_stat_activity WHERE pg_stat_activity.datname = '{}' AND \
                                   pid <> pg_backend_pid()",
            &old_db
        );
        try!(conn.execute(&disco_query, &[]));
        let drop_query = format!("DROP DATABASE {}", &old_db);
        try!(conn.execute(&drop_query, &[]));
        Ok(())
    }
/// Kick everyone off the database and destroy the data at the provided URI
Kick everyone off the database and destroy the data at the provided URI
Kick everyone off the database and destroy the data at the provided URI
pub fn destroy(uri: &str) -> Result<()> {
        let params = try!(uri.into_connect_params().map_err(|_| ErrorKind::UriParse));
        let old_db = try!(params.database().ok_or_else(|| {
            ErrorKind::Arg(format!("No database specified to destroy in {}.", uri))
        }));
        let pg_params = param_into_builder(&params).database("postgres").build(
            params
                .host()
                .clone(),
        );
        let conn = Connection::connect(pg_params, postgres::TlsMode::None)?;
        let disco_query = format!(
            "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM \
                                   pg_stat_activity WHERE pg_stat_activity.datname = '{}' AND \
                                   pid <> pg_backend_pid()",
            &old_db
        );
        try!(conn.execute(&disco_query, &[]));
        let drop_query = format!("DROP DATABASE {}", &old_db);
        try!(conn.execute(&drop_query, &[]));
        Ok(())
    }
pub fn destroy ( uri : & str ) -> Result < ( ) > { let params = try ! ( uri into_connect_params ( ) map_err ( ErrorKind UriParse ) ) ; let old_db = try ! ( params database ( ) ok_or_else ( { ErrorKind Arg ( format ( " " uri ) ) } ) ) ; let pg_params = param_into_builder ( & params ) . database ( " " ) . build ( params . host ( ) . clone ( ) , ) ; let conn = Connection :: connect ( pg_params , postgres :: TlsMode :: None ) ? ; let disco_query = format ! ( " \
 \
 " old_db ) ; try ! ( conn execute ( disco_query [ ] ) ) ; let drop_query = format ! ( " " old_db ) ; try ! ( conn execute ( drop_query [ ] ) ) ; Ok ( ( ) ) }
Kick everyone off the database and destroy the data at the provided URI
Kick everyone off the database and destroy the data at the provided URI
uri
&str
uri
&str