Overview
TheStatement struct represents an unprepared CQL statement that can be executed on a server. It contains the CQL query text along with various execution options.
For reusable statements or statements with bound values, prefer using PreparedStatement which offers better performance and type safety.
Type Definition
scylla/src/statement/unprepared.rs:16
Constructor
new
Creates a new Statement from a CQL query string.
The CQL statement text (e.g.,
"SELECT * FROM my_table")A new statement instance with default configuration
Configuration Methods
Paging
set_page_size
Sets the page size for paged query execution.
Number of rows to fetch per page. Must be positive. Default is 5000.
page_size is non-positive.
with_page_size
Builder-style method to set page size.
get_page_size
Returns the configured page size.
Consistency
set_consistency
Sets the consistency level for this statement.
Consistency level (e.g.,
Consistency::Quorum)unset_consistency
Removes the consistency override, falling back to the execution profile.
get_consistency
Returns the overridden consistency level, if set.
Serial Consistency
set_serial_consistency
Sets the serial consistency for lightweight transactions (LWTs).
Serial consistency level for LWT operations
unset_serial_consistency
Removes the serial consistency override.
get_serial_consistency
Returns the configured serial consistency.
Idempotence
set_is_idempotent
Marks whether the statement is idempotent.
true if the statement can be safely retriedget_is_idempotent
Tracing
set_tracing
Enables or disables CQL tracing.
true to enable tracingget_tracing
Timestamp
set_timestamp
Sets a client-provided timestamp in microseconds.
Timestamp in microseconds since Unix epoch, or
None for server-side timestampget_timestamp
Timeout
set_request_timeout
Sets the client-side request timeout.
Maximum time to wait for the request, or
None to use execution profile timeoutget_request_timeout
Policies
set_retry_policy
Overrides the retry policy for this statement.
Custom retry policy, or
None to use the execution profile’s policyget_retry_policy
set_load_balancing_policy
Overrides the load balancing policy for this statement.
get_load_balancing_policy
Execution Profile
set_execution_profile_handle
Associates the statement with an execution profile.
get_execution_profile_handle
History Listener
set_history_listener
Sets a listener to track query execution events.
remove_history_listener
Removes the history listener.
Trait Implementations
From<String>
String into a Statement.
From<&str>
Statement.
Example Usage
See Also
- PreparedStatement - For prepared statements with better performance
- Batch - For executing multiple statements atomically
- RetryPolicy - Controlling retry behavior
- LoadBalancingPolicy - Controlling request routing
