Trait cratedb::sql::QueryRunner [−][src]
pub trait QueryRunner { fn query<SQL, S>(
&self,
sql: SQL,
params: Option<Box<S>>
) -> Result<(f64, RowIterator), CrateDBError>
where
SQL: Into<String>,
S: Serialize; fn bulk_query<SQL, S>(
&self,
sql: SQL,
params: Box<S>
) -> Result<(f64, Vec<i64>), CrateDBError>
where
SQL: Into<String>,
S: Serialize; }
Required Methods
fn query<SQL, S>(
&self,
sql: SQL,
params: Option<Box<S>>
) -> Result<(f64, RowIterator), CrateDBError> where
SQL: Into<String>,
S: Serialize,
&self,
sql: SQL,
params: Option<Box<S>>
) -> Result<(f64, RowIterator), CrateDBError> where
SQL: Into<String>,
S: Serialize,
Runs a query. Returns the results and the duration
Example
ⓘThis example is not tested
use cratedb::Cluster; use cratedb::row::ByIndex; let node = "http://play.crate.io"; let mut c: Cluster = Cluster::from_string(node).unwrap(); let (elapsed, rows) = c.query("select hostname from sys.nodes", None::<Box<Nothing>>).unwrap(); for r in rows { println!("{}", r.as_string(0).unwrap()); }
fn bulk_query<SQL, S>(
&self,
sql: SQL,
params: Box<S>
) -> Result<(f64, Vec<i64>), CrateDBError> where
SQL: Into<String>,
S: Serialize,
&self,
sql: SQL,
params: Box<S>
) -> Result<(f64, Vec<i64>), CrateDBError> where
SQL: Into<String>,
S: Serialize,
Runs a query. Returns the results and the duration
ⓘThis example is not tested
use doc::Cluster; use doc::row::ByIndex; let node = "http://play.crate.io"; let mut c: Cluster = Cluster::from_string(node).unwrap(); let (elapsed, rows) = c.bulk_query("select hostname from sys.nodes", Box::new("")).unwrap(); for r in rows { println!(r.as_string(0).unwrap()); }