pub struct Statement { /* private fields */ }Expand description
A SQL statement for execution on Spanner.
§Example
let client = Spanner::builder().build().await.unwrap();
let db = client.database_client("projects/p/instances/i/databases/d").build().await.unwrap();
let tx = db.single_use().build();
let stmt = Statement::builder("SELECT * FROM users WHERE id = @id")
.add_param("id", &42)
.build();
let mut rs = tx.execute_query(stmt).await?;
while let Some(row) = rs.next().await {
let row = row?;
// process row
}Implementations§
Source§impl Statement
impl Statement
Sourcepub fn builder(sql: impl Into<String>) -> StatementBuilder
pub fn builder(sql: impl Into<String>) -> StatementBuilder
Creates a new statement builder.
Sourcepub fn set_query_mode(self, mode: QueryMode) -> Self
pub fn set_query_mode(self, mode: QueryMode) -> Self
Sets the query mode to use for this statement.
§Example
let statement = Statement::builder("SELECT * FROM users WHERE id = @id")
.add_param("id", &42)
.build();
let mut query_plan = tx.execute_query(statement.clone().set_query_mode(QueryMode::Plan)).await?;This method consumes the statement and returns a new one with the specified mode.
Trait Implementations§
Source§impl From<StatementBuilder> for Statement
impl From<StatementBuilder> for Statement
Source§fn from(builder: StatementBuilder) -> Self
fn from(builder: StatementBuilder) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for Statement
impl !UnwindSafe for Statement
impl Freeze for Statement
impl Send for Statement
impl Sync for Statement
impl Unpin for Statement
impl UnsafeUnpin for Statement
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request