pub struct CopyFromQuery<T, Action> { /* private fields */ }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,
impl<T> CopyFromQuery<T, NotSet>where
T: Table,
Sourcepub fn from_raw_data<F, C, E>(
self,
_target: C,
action: F,
) -> CopyFromQuery<T, CopyFrom<C, F>>
pub fn from_raw_data<F, C, E>( self, _target: C, action: F, ) -> CopyFromQuery<T, CopyFrom<C, F>>
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
Sourcepub fn from_insertable<I>(
self,
insertable: I,
) -> CopyFromQuery<T, InsertableWrapper<I>>where
InsertableWrapper<I>: CopyFromExpression<T>,
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>>
impl<T, C, F> CopyFromQuery<T, CopyFrom<C, F>>
Sourcepub fn with_format(self, format: CopyFormat) -> Self
pub fn with_format(self, format: CopyFormat) -> Self
The format used for the copy statement
See the PostgreSQL documentation for more details.
Sourcepub fn with_freeze(self, freeze: bool) -> Self
pub fn with_freeze(self, freeze: bool) -> Self
Whether or not the freeze option is set
See the PostgreSQL documentation for more details.
Sourcepub fn with_delimiter(self, delimiter: char) -> Self
pub fn with_delimiter(self, delimiter: char) -> Self
Which delimiter should be used for textual input formats
See the PostgreSQL documentation for more details.
Sourcepub fn with_null(self, null: impl Into<String>) -> Self
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.
Sourcepub fn with_quote(self, quote: char) -> Self
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.
Sourcepub fn with_escape(self, escape: char) -> Self
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.
Sourcepub fn with_default(self, default: impl Into<String>) -> Self
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)
Sourcepub fn with_header(self, header: CopyHeader) -> Self
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, A> ExecuteCopyFromDsl<PgConnection> for CopyFromQuery<T, A>where
A: CopyFromExpression<T>,
Available on crate feature postgres only.
impl<T, A> ExecuteCopyFromDsl<PgConnection> for CopyFromQuery<T, A>where
A: CopyFromExpression<T>,
postgres only.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.
impl<T, A, C> ExecuteCopyFromDsl<PooledConnection<ConnectionManager<C>>> for CopyFromQuery<T, A>where
A: CopyFromExpression<T>,
C: R2D2Connection<Backend = Pg> + 'static,
Self: ExecuteCopyFromDsl<C>,
r2d2 only.Source§type Error = <CopyFromQuery<T, A> as ExecuteCopyFromDsl<C>>::Error
type Error = <CopyFromQuery<T, A> as ExecuteCopyFromDsl<C>>::Error
Source§fn execute(
self,
conn: &mut PooledConnection<ConnectionManager<C>>,
) -> Result<usize, Self::Error>
fn execute( self, conn: &mut PooledConnection<ConnectionManager<C>>, ) -> Result<usize, Self::Error>
Auto Trait Implementations§
impl<T, Action> Freeze for CopyFromQuery<T, Action>
impl<T, Action> RefUnwindSafe for CopyFromQuery<T, Action>where
T: RefUnwindSafe,
Action: RefUnwindSafe,
impl<T, Action> Send for CopyFromQuery<T, Action>
impl<T, Action> Sync for CopyFromQuery<T, Action>
impl<T, Action> Unpin for CopyFromQuery<T, Action>
impl<T, Action> UnwindSafe for CopyFromQuery<T, Action>where
T: UnwindSafe,
Action: UnwindSafe,
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> AggregateDistinct<Self>where
Self: DistinctDsl,
fn aggregate_distinct(self) -> AggregateDistinct<Self>where
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> AggregateAll<Self>where
Self: AllDsl,
fn aggregate_all(self) -> AggregateAll<Self>where
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> AggregateFilter<Self, P>
fn aggregate_filter<P>(self, f: P) -> AggregateFilter<Self, P>
Source§fn aggregate_order<O>(self, o: O) -> AggregateOrder<Self, O>where
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> AggregateOrder<Self, O>where
Self: OrderAggregateDsl<O>,
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.