Struct diesel::pg::CopyFromQuery

source ·
pub struct CopyFromQuery<T, Action> { /* private fields */ }
Available on crate feature postgres_backend only.
Expand description

The structure returned by copy_from

The from_raw_data and the from_insertable methods allow to configure the data copied into the database

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

Implementations§

source§

impl<T> CopyFromQuery<T, NotSet>
where T: Table,

source

pub fn from_raw_data<F, C, E>( self, _target: C, action: F ) -> CopyFromQuery<T, CopyFrom<C, F>>
where C: CopyTarget<Table = T>, F: Fn(&mut dyn Write) -> Result<(), E>,

Copy data into the database by directly providing the data in the corresponding format

target specifies the column selection that is the target of the COPY FROM statement action expects a callback which accepts a std::io::Write argument. The necessary format accepted by this writer sink depends on the options provided via the with_* methods

source

pub fn from_insertable<I>( self, insertable: I ) -> CopyFromQuery<T, InsertableWrapper<I>>
where InsertableWrapper<I>: CopyFromExpression<T>,

Copy a set of insertable values into the database.

The insertable argument is expected to be a Vec<I>, &[I] or similar, where I needs to implement Insertable<T>. If you use the #[derive(Insertable)] derive macro make sure to also set the #[diesel(treat_none_as_default_value = false)] option to disable the default value handling otherwise implemented by #[derive(Insertable)].

This uses the binary format. It internally configures the correct set of settings and does not allow to set other options

source§

impl<T, C, F> CopyFromQuery<T, CopyFrom<C, F>>

source

pub fn with_format(self, format: CopyFormat) -> Self

The format used for the copy statement

See the PostgreSQL documentation for more details.

source

pub fn with_freeze(self, freeze: bool) -> Self

Whether or not the freeze option is set

See the PostgreSQL documentation for more details.

source

pub fn with_delimiter(self, delimiter: char) -> Self

Which delimiter should be used for textual input formats

See the PostgreSQL documentation for more details.

source

pub fn with_null(self, null: impl Into<String>) -> Self

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

See the PostgreSQL documentation for more details.

source

pub fn with_quote(self, quote: char) -> Self

Which quote character should be used for textual input formats

See the PostgreSQL documentation for more details.

source

pub fn with_escape(self, escape: char) -> Self

Which escape character should be used for textual input formats

See the PostgreSQL documentation for more details.

source

pub fn with_default(self, default: impl Into<String>) -> Self

Which string should be used to indicate that the default value should be used in place of that string for textual formats

See the PostgreSQL documentation for more details.

(This parameter was added with PostgreSQL 16)

source

pub fn with_header(self, header: CopyHeader) -> Self

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, Action: Debug> Debug for CopyFromQuery<T, Action>

source§

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

Formats the value using the given formatter. Read more
source§

impl<T, A> ExecuteCopyFromDsl<PgConnection> for CopyFromQuery<T, A>
where A: CopyFromExpression<T>,

Available on crate feature postgres only.
§

type Error = <A as CopyFromExpression<T>>::Error

The error type returned by the execute function
source§

fn execute(self, conn: &mut PgConnection) -> Result<usize, A::Error>

See the trait documentation for details
source§

impl<T, A, C> ExecuteCopyFromDsl<PooledConnection<ConnectionManager<C>>> for CopyFromQuery<T, A>
where A: CopyFromExpression<T>, C: R2D2Connection<Backend = Pg> + 'static, Self: ExecuteCopyFromDsl<C>,

Available on crate feature r2d2 only.
§

type Error = <CopyFromQuery<T, A> as ExecuteCopyFromDsl<C>>::Error

The error type returned by the execute function
source§

fn execute( self, conn: &mut PooledConnection<ConnectionManager<C>> ) -> Result<usize, Self::Error>

See the trait documentation for details

Auto Trait Implementations§

§

impl<T, Action> Freeze for CopyFromQuery<T, Action>
where T: Freeze, Action: Freeze,

§

impl<T, Action> RefUnwindSafe for CopyFromQuery<T, Action>
where T: RefUnwindSafe, Action: RefUnwindSafe,

§

impl<T, Action> Send for CopyFromQuery<T, Action>
where T: Send, Action: Send,

§

impl<T, Action> Sync for CopyFromQuery<T, Action>
where T: Sync, Action: Sync,

§

impl<T, Action> Unpin for CopyFromQuery<T, Action>
where T: Unpin, Action: Unpin,

§

impl<T, Action> UnwindSafe for CopyFromQuery<T, Action>
where T: UnwindSafe, Action: 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>

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

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

§

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>,

§

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