pub struct Redshift { /* private fields */ }Expand description
Client for executing queries against an Amazon Redshift cluster.
Uses ConnectorX under the hood and
returns results as Arrow RecordBatches.
Implementations§
Source§impl Redshift
impl Redshift
Sourcepub fn new(
username: impl ToString,
password: impl ToString,
host: impl ToString,
port: Option<u16>,
database: impl ToString,
) -> Self
pub fn new( username: impl ToString, password: impl ToString, host: impl ToString, port: Option<u16>, database: impl ToString, ) -> Self
Creates a new Redshift client.
port defaults to 5439 when None.
§Examples
use redshift_iam::Redshift;
use secrecy::ExposeSecret;
let r = Redshift::new("alice", "s3cr3t", "my-host.example.com", None, "analytics");
let cs = r.connection_string();
assert!(cs.expose_secret().starts_with("postgresql://"));
assert!(cs.expose_secret().contains(":5439/"));
assert!(cs.expose_secret().contains("my-host.example.com"));
assert!(cs.expose_secret().contains("/analytics"));Sourcepub fn connection_string(&self) -> SecretString
pub fn connection_string(&self) -> SecretString
Builds the URL-encoded postgresql:// connection string used by ConnectorX.
Credentials are percent-encoded so that special characters (e.g. @) do not
corrupt the URL. The result is wrapped in a SecretString to prevent
accidental logging.
§Examples
use redshift_iam::Redshift;
use secrecy::ExposeSecret;
// Special characters in passwords are percent-encoded
let r = Redshift::new("user", "p@ssword", "host", None, "db");
let cs = r.connection_string();
assert!(cs.expose_secret().contains("p%40ssword"));
assert!(cs.expose_secret().contains("cxprotocol=cursor"));Sourcepub fn execute(
&self,
query: impl ToString,
) -> Result<Vec<RecordBatch>, ConnectorXOutError>
pub fn execute( &self, query: impl ToString, ) -> Result<Vec<RecordBatch>, ConnectorXOutError>
Executes query and returns the results as a Vec<RecordBatch>.
Auto Trait Implementations§
impl Freeze for Redshift
impl RefUnwindSafe for Redshift
impl Send for Redshift
impl Sync for Redshift
impl Unpin for Redshift
impl UnsafeUnpin for Redshift
impl UnwindSafe for Redshift
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.