Was this page helpful?
Decimal
is represented as bigdecimal::BigDecimal
use scylla::IntoTypedRows;
use bigdecimal::BigDecimal;
use std::str::FromStr;
// Insert a decimal into the table
let to_insert: BigDecimal = BigDecimal::from_str("12345.0")?;
session
.query("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
.await?;
// Read a decimal from the table
if let Some(rows) = session.query("SELECT a FROM keyspace.table", &[]).await?.rows {
for row in rows.into_typed::<(BigDecimal,)>() {
let (decimal_value,): (BigDecimal,) = row?;
}
}
Was this page helpful?