Files
simple-rust-tests/__database/sqlx/src/main.rs
2021-03-21 17:45:27 +08:00

19 lines
423 B
Rust

use sqlx::sqlite::SqlitePoolOptions;
#[async_std::main]
// or #[tokio::main]
async fn main() -> Result<(), sqlx::Error> {
let pool = SqlitePoolOptions::new()
.max_connections(5)
.connect("sqlite::memory:")
.await?;
println!("{:#?}", pool);
let row: (i64,) = sqlx::query_as("SELECT $1")
.bind(150_i64)
.fetch_one(&pool).await?;
println!("{:#?}", row);
Ok(())
}