diesel::pg

Struct CopyToQuery

Source
pub struct CopyToQuery<T, O> { /* private fields */ }
Available on crate feature postgres_backend only.
Expand description

The structure returned by copy_to

The load and the load_raw methods allow to receive the configured data from the database. If you don’t have any special needs you should prefer using the more convenient load method.

The with_* methods allow to configure the settings used for the copy statement.

Implementations§

Source§

impl<T> CopyToQuery<T, NotSet>
where T: CopyTarget,

Source

pub fn load<U, C>( self, conn: &mut C, ) -> QueryResult<impl Iterator<Item = QueryResult<U>> + '_>
where U: FromSqlRow<<U::SelectExpression as Expression>::SqlType, Pg> + Selectable<Pg>, U::SelectExpression: AppearsOnTable<T::Table> + CopyTarget<Table = T::Table>, C: ExecuteCopyToConnection,

Copy data from the database by returning an iterator of deserialized data

This function allows to easily load data from the database via a COPY TO statement. It does not allow to configure any settings via the with_* method, as it internally sets the required options itself. It will use the binary format to deserialize the result into the specified type U. Column selection is performed via Selectable.

Source§

impl<T, O> CopyToQuery<T, O>
where O: CopyToMarker, T: CopyTarget,

Source

pub fn load_raw<C>(self, conn: &mut C) -> QueryResult<impl BufRead + '_>
where C: ExecuteCopyToConnection,

Copy data from the database by directly accessing the provided response

This function returns a type that implements std::io::BufRead which allows to directly read the data as provided by the database. The exact format depends on what options are set via the various with_* methods.

Source

pub fn with_format(self, format: CopyFormat) -> CopyToQuery<T, CopyToOptions>

The format used for the copy statement

See the PostgreSQL documentation for more details.

Source

pub fn with_freeze(self, freeze: bool) -> CopyToQuery<T, CopyToOptions>

Whether or not the freeze option is set

See the PostgreSQL documentation for more details.

Source

pub fn with_delimiter(self, delimiter: char) -> CopyToQuery<T, CopyToOptions>

Which delimiter should be used for textual output formats

See the PostgreSQL documentation for more details.

Source

pub fn with_null(self, null: impl Into<String>) -> CopyToQuery<T, CopyToOptions>

Which string should be used in place of a NULL value for textual output formats

See the PostgreSQL documentation for more details.

Source

pub fn with_quote(self, quote: char) -> CopyToQuery<T, CopyToOptions>

Which quote character should be used for textual output formats

See the PostgreSQL documentation for more details.

Source

pub fn with_escape(self, escape: char) -> CopyToQuery<T, CopyToOptions>

Which escape character should be used for textual output formats

See the PostgreSQL documentation for more details.

Source

pub fn with_header(self, set: bool) -> CopyToQuery<T, CopyToOptions>

Is a header provided as part of the textual input or not

See the PostgreSQL documentation for more details.

Trait Implementations§

Source§

impl<T: Debug, O: Debug> Debug for CopyToQuery<T, O>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, O> Freeze for CopyToQuery<T, O>
where T: Freeze, O: Freeze,

§

impl<T, O> RefUnwindSafe for CopyToQuery<T, O>

§

impl<T, O> Send for CopyToQuery<T, O>
where T: Send, O: Send,

§

impl<T, O> Sync for CopyToQuery<T, O>
where T: Sync, O: Sync,

§

impl<T, O> Unpin for CopyToQuery<T, O>
where T: Unpin, O: Unpin,

§

impl<T, O> UnwindSafe for CopyToQuery<T, O>
where T: UnwindSafe, O: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoSql for T

Source§

fn into_sql<T>(self) -> AsExprOf<Self, T>

Convert self to an expression for Diesel’s query builder. Read more
Source§

fn as_sql<'a, T>(&'a self) -> AsExprOf<&'a Self, T>
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T