Struct diesel::pg::CopyFromQuery
source · pub struct CopyFromQuery<T, Action> { /* private fields */ }
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.