Struct 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: DatatypeIndexes

Implementations§

Source§

impl PreppedGridData

Source

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.

Source

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§

Source§

impl Debug for PreppedGridData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.