pub struct Glue {
pub primary: String,
/* private fields */
}
Expand description
Glue
Glue is the interface for interacting with MultiSQL; a Glue instance comprises any number of stores, each with their own identifier. Once built, one will typically interact with Glue via queries.
There is a number of ways to deposit queries however, depending on the desired output:
Glue::execute()
– Might be considered the most generic. Replies with a Result<Payload> (payload being the response from any type of query).Glue::execute_many()
– Same asexecute()
but will find any number of seperate queries in given text and provide a Vec in response.Glue::select_as_string()
– Provides data, only forSELECT
queries, as Strings (rather than Values).Glue::select_as_json()
– Provides data, only forSELECT
queries, as one big String; generally useful for webby interactions.
Fields
primary: String
Implementations
sourceimpl Glue
impl Glue
pub async fn update(
&mut self,
table: &TableWithJoins,
selection: &Option<Expr>,
assignments: &[Assignment]
) -> Result<Payload>
sourceimpl Glue
impl Glue
pub async fn alter_table(
&mut self,
name: &ObjectName,
operation: &AlterTableOperation
) -> Result<()>
sourceimpl Glue
impl Glue
pub async fn create_index(
&mut self,
table: &ObjectName,
name: &ObjectName,
columns: &[OrderByExpr],
unique: bool,
if_not_exists: bool
) -> Result<()>
sourceimpl Glue
impl Glue
pub async fn create_table(
&mut self,
name: &ObjectName,
column_defs: &[ColumnDef],
if_not_exists: bool
) -> Result<()>
sourceimpl Glue
impl Glue
pub async fn drop(
&mut self,
object_type: &ObjectType,
names: &[ObjectName],
if_exists: bool
) -> Result<()>
sourceimpl Glue
impl Glue
pub async fn set_variable(
&mut self,
variable: &Ident,
value: &[SetVariableValue]
) -> Result<()>
sourceimpl Glue
impl Glue
pub fn get_database(
&self,
db_ref: &Option<String>
) -> Result<MutexGuard<'_, Box<DatabaseInner>>>
pub fn get_mut_database(
&mut self,
db_ref: &Option<String>
) -> Result<&mut Box<DatabaseInner>>
pub fn get_context(&self) -> Result<MutexGuard<'_, Context>>
pub fn get_mut_context(&mut self) -> Result<&mut Context>
pub fn get_database_list(&self) -> Vec<&String>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
sourceimpl Glue
impl Glue
sourcepub fn select_as_json(&mut self, query: &str) -> Result<String>
pub fn select_as_json(&mut self, query: &str) -> Result<String>
sourcepub fn select_as_json_with_headers(&mut self, query: &str) -> String
pub fn select_as_json_with_headers(&mut self, query: &str) -> String
sourcepub fn select_as_string(&mut self, query: &str) -> Result<Vec<Vec<String>>>
pub fn select_as_string(&mut self, query: &str) -> Result<Vec<Vec<String>>>
Only for SELECT
queries.
sourcepub fn select_as_csv(&mut self, query: &str) -> Result<String>
pub fn select_as_csv(&mut self, query: &str) -> Result<String>
Only for SELECT
queries.
sourceimpl Glue
impl Glue
sourcepub fn new_multi_glue(glues: Vec<Glue>) -> Self
pub fn new_multi_glue(glues: Vec<Glue>) -> Self
Merges existing Glue instances
sourcepub fn extend_many_glues(&mut self, glues: Vec<Glue>)
pub fn extend_many_glues(&mut self, glues: Vec<Glue>)
Merge existing Glue with Vec of other Glues For example:
use multisql::{SledDatabase, Database, Glue};
let storage = SledDatabase::new("data/example_location/example")
.map(Database::new_sled)
.expect("Database Creation Failed");
let mut glue = Glue::new(String::from("main"), storage);
glue.execute_many("
DROP TABLE IF EXISTS test;
CREATE TABLE test (id INTEGER);
INSERT INTO test VALUES (1),(2);
SELECT * FROM test WHERE id > 1;
");
let other_storage = SledDatabase::new("data/example_location/example_other")
.map(Database::new_sled)
.expect("Database Creation Failed");
let mut other_glue = Glue::new(String::from("other"), other_storage);
glue.extend_many_glues(vec![other_glue]);
pub fn extend_glue(&mut self, glue: Glue)
sourcepub fn try_extend_from_path(
&mut self,
database_name: String,
database_path: String
) -> Result<bool>
pub fn try_extend_from_path(
&mut self,
database_name: String,
database_path: String
) -> Result<bool>
sourceimpl Glue
impl Glue
sourcepub fn execute_many(&mut self, query: &str) -> Result<Vec<Payload>>
pub fn execute_many(&mut self, query: &str) -> Result<Vec<Payload>>
Will execute a set of queries.
sourcepub fn execute_parsed(&mut self, query: Query) -> Result<Payload>
pub fn execute_parsed(&mut self, query: Query) -> Result<Payload>
Will execute a pre-parsed query (see Glue::pre_parse() for more).
Auto Trait Implementations
impl RefUnwindSafe for Glue
impl !Send for Glue
impl !Sync for Glue
impl Unpin for Glue
impl UnwindSafe for Glue
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more