pub struct PreppedGridData {
pub data: Vec<Vec<FormattedData>>,
pub conn: Connection,
pub data_indexes: DatatypeIndexes,
}
Fields§
§data: Vec<Vec<FormattedData>>
§conn: Connection
§data_indexes: DatatypeIndexes
Implementations§
Source§impl PreppedGridData
impl PreppedGridData
Sourcepub fn insert(
self,
table_name: &str,
) -> Result<Arc<Connection>, OracleSqlToolsError>
pub fn insert( self, table_name: &str, ) -> Result<Arc<Connection>, OracleSqlToolsError>
Inserts the input data into a table
Splits the data by the number of CPU threads in the host machine. Each thread creates it’s own oracle::Batch
which helps the upload speed for large datasets.
§Usage
It’s recommended to open a Connection
first so if there’s an issue connecting to the database, it’ll error faster.
let conn: oracle::Connection = match Connection::connect("<USERNAME>", "<PASSWORD>", "<IP ADDRESS>")?;
let data: Vec<Vec<String>> = vec![
vec!["ColA".to_string(), "ColB".to_string(), "ColC".to_string()],
vec!["A1".to_string(), "B1".to_string(), "C1".to_string()],
vec!["A2".to_string(), "B2".to_string(), "C2".to_string()],
vec!["A3".to_string(), "B3".to_string(), "C3".to_string()],
];
let res: Arc<Connection> = data.prep_data(conn).insert("MY_TABLE")?;
// `res` has the executed Batch(es), you only need to commit it
res.commit()?;
Ok(())
‘res’ is Atomically Referencing ‘conn’ because Connection
cannot be copied, and it causes a lifetime conflict with the spawned threads when borrowed normally.
Sourcepub fn insert_single_thread(
self,
table_name: &str,
) -> Result<Arc<Connection>, OracleSqlToolsError>
pub fn insert_single_thread( self, table_name: &str, ) -> Result<Arc<Connection>, OracleSqlToolsError>
Inserts the input data into a table using only a single thread
Useful if you have a procedure or trigger in your database that groups data in a table or view via insert
See the .insert() on how to use.
let res: Arc<Connection> = data.prep_data(conn).insert_single_thread("MY_TABLE")?;
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PreppedGridData
impl RefUnwindSafe for PreppedGridData
impl Send for PreppedGridData
impl Sync for PreppedGridData
impl Unpin for PreppedGridData
impl UnwindSafe for PreppedGridData
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
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more