forked from scylladb/scylla-rust-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.rs
26 lines (20 loc) · 742 Bytes
/
auth.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use anyhow::Result;
use scylla::SessionBuilder;
#[tokio::main]
async fn main() -> Result<()> {
let uri = std::env::var("SCYLLA_URI").unwrap_or_else(|_| "127.0.0.1:9042".to_string());
println!("Connecting to {} with cassandra superuser ...", uri);
let session = SessionBuilder::new()
.known_node(uri)
.user("cassandra", "cassandra")
.build()
.await
.unwrap();
session.query_unpaged("CREATE KEYSPACE IF NOT EXISTS examples_ks WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}", &[]).await.unwrap();
session
.query_unpaged("DROP TABLE IF EXISTS examples_ks.auth;", &[])
.await
.unwrap();
println!("Ok.");
Ok(())
}