diesel::pg

Struct 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.
Source§

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.
Source§

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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