Struct basex::query::query::Query [−][src]
pub struct Query<T> where
T: DatabaseStream, {
id: String,
connection: Connection<T>,
}Expand description
Represents an XQuery code uniquely identified by the database.
Database query is created out of an XQuery syntax string. The XQuery gets send to the database and associated with an ID. Once the query ID is assigned, the XQuery cannot be changed, but the client may bind arguments or context for it.
Once happy with the arguments bound or context set, the Query can be executed or analysed.
Fields
id: Stringconnection: Connection<T>Implementations
Binds a value to a variable. The type will be ignored if the value is None.
Executes the query and returns its response.
Example
use basex::{Client, ClientError};
use std::io::Read;
let mut client = Client::connect("localhost", 1984, "admin", "admin")?;
let mut xquery = "declare variable $points := 30;
<polygon>
{
for $i in 1 to $points
let $angle := 2 * math:pi() * number($i div $points)
return <point x=\"{round(math:cos($angle), 8)}\" y=\"{round(math:sin($angle), 8)}\"></point>
}
</polygon>".as_bytes();
let query = client.query(&mut xquery)?;
let mut result = String::new();
let mut response = query.execute()?;
response.read_to_string(&mut result)?;
println!("{}", result);Returns a string with query compilation and profiling info.
Returns a string with all query serialization parameters, which can e.g. be assigned to the SERIALIZER option.
Binds a value to the context. The type will be ignored if the value is None.