# Connect with Rust

To connect SingleStore with Rust, use [SQLx](https://github.com/launchbadge/sqlx) with its MySQL feature. Refer to the following **Cargo.toml** file:

```toml
[package]
name = "rust-singlestore-connect"
version = "0.1.0"
edition = "2021"

[dependencies]
sqlx = { version = "0.5", features = ["runtime-tokio-native-tls", "mysql"] }
tokio = { version = "1", features = ["full"] }
```

For more information, see [SQLx Docs](https://github.com/launchbadge/sqlx).

Here's a sample **main.rs** file:

```rust
use sqlx::mysql::{MySqlConnectOptions, MySqlPoolOptions};

#[tokio::main]
async fn main() -> Result<(), sqlx::Error> {
    let opts = MySqlConnectOptions::new()
        .host("svc-ab8077f6-7b03-4ba3-b557-063c53eff943-ddl.aws-oregon-2.svc.singlestore.com")
        .username("admin")
        .password("PASSWORD");

    let pool = MySqlPoolOptions::new().connect_with(opts).await?;

    let row: (i64,) = sqlx::query_as("SELECT ?")
        .bind(150_i64)
        .fetch_one(&pool)
        .await?;

    assert_eq!(row.0, 150);

    Ok(())
}
```

***

Modified at: May 12, 2026

Source: [/db/v9.1/developer-resources/connect-with-application-development-tools/connect-with-rust/](https://docs.singlestore.com/db/v9.1/developer-resources/connect-with-application-development-tools/connect-with-rust/)

(An index of the documentation is available at /llms.txt)
