launchbadge / sqlx
Get started
Taken from the repository's own files on 22 Oct 2026. RepoPilot has not run these commands.
Prerequisites
The files RepoPilot read do not name a runtime version or package manager.
Commands
No scripts found at the top level of the repository. Check Cargo.toml .
Install and use
README.mduse sqlx::postgres::PgPoolOptions;
// use sqlx::mysql::MySqlPoolOptions;
// etc.
#[async_std::main] // Requires the `attributes` feature of `async-std`
// or #[tokio::main]
// or #[actix_web::main]
async fn main() -> Result<(), sqlx::Error> {
// Create a connection pool
// for MySQL/MariaDB, use MySqlPoolOptions::new()
// for SQLite, use SqlitePoolOptions::new()
// etc.
let pool = PgPoolOptions::new()
.max_connections(5)
.connect("postgres://postgres:password@localhost/test").await?;
// Make a simple query to return the given parameter (use a question mark `?` instead of `$1` for MySQL/MariaDB)
let row: (i64,) = sqlx::query_as("SELECT $1")
.bind(150_i64)
.fetch_one(&pool).await?;
assert_eq!(row.0, 150);
Ok(())
}
Developing
CONTRIBUTING.md- Make sure you have a GitHub account.
- Take a look at existing issues.
- If you need to create an issue:
- Make sure to clearly describe it.
- Including steps to reproduce when it is a bug.
- Include the version of SQLx used.
- Include the database driver and version.
- Include the database version.