mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-09-30 06:22:01 +00:00
18 lines
504 B
Rust
18 lines
504 B
Rust
use sqlx::types::Uuid;
|
|
|
|
#[async_std::test]
|
|
async fn postgres_query() -> sqlx::Result<()> {
|
|
let mut conn =
|
|
sqlx::Connection::<sqlx::Postgres>::open(&dotenv::var("DATABASE_URL").unwrap()).await?;
|
|
|
|
let uuid: Uuid = "256ba9c8-0048-11ea-b0f0-8f04859d047e".parse().unwrap();
|
|
let account_id = sqlx::query!("SELECT id from accounts where id != $1", uuid)
|
|
.as_scalar::<Uuid>()
|
|
.fetch_one(&mut conn)
|
|
.await?;
|
|
|
|
println!("account ID: {:?}", account_id);
|
|
|
|
Ok(())
|
|
}
|