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> 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>
. 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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
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.