examples: add a prepared statement example
use anyhow::Result;
use scylla::transport::session::Session;
-use scylla::transport::Compression;
use std::env;
+use scylla::values;
#[tokio::main]
async fn main() -> Result<()> {
@@ -9,7 +9,7 @@ async fn main() -> Result<()> {
println!("Connecting to {} ...", uri);
- let session = Session::connect(uri, Some(Compression::LZ4)).await?;
+ let session = Session::connect(uri, None).await?;
session.query("CREATE KEYSPACE IF NOT EXISTS ks WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1}").await?;
@@ -17,6 +17,9 @@ async fn main() -> Result<()> {
session.query("INSERT INTO ks.t (a, b, c) VALUES (1, 2, 'abc')").await?;
+ let prepared = session.prepare("INSERT INTO ks.t (a, b, c) VALUES (?, 7, ?)").await?;
+ session.execute(&prepared, values!(42_i32, "I'm prepared!")).await?;
+
if let Some(rs) = session.query("SELECT a, b, c FROM ks.t").await? {
for r in rs {
let a = r.columns[0].as_ref().unwrap().as_int().unwrap();
