Struct oracle_sql_tools::statements::PreppedGridData
source · pub struct PreppedGridData {
pub data: Vec<Vec<FormattedData>>,
pub conn: Connection,
pub data_indexes: DatatypeIndexes,
}Fields§
§data: Vec<Vec<FormattedData>>§conn: Connection§data_indexes: DatatypeIndexesImplementations§
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