Module sqlx_core::database

source ·
Expand description

Traits to represent a database driver.

Support

Tier 1

Tier 1 support can be thought of as “guaranteed to work”. Automated testing is setup to ensure a high level of stability and functionality.

DatabaseVersionDriver
MariaDB10.1+mysql
Microsoft SQL Server2019mssql
MySQL5.6, 5.7, 8.0mysql
PostgreSQL9.5+postgres
SQLite3.20.1+sqlite

Tier 2

Tier 2 support can be thought as “should work”. No specific automated testing is done, at this time, but there are efforts to ensure compatibility. Tier 2 support also includes database distributions that provide protocols that closely match a database from Tier 1.

No databases are in tier 2 at this time.

Any

Selecting a database driver is, by default, a compile-time decision. SQLx is designed this way to take full advantage of the performance and type safety made available by Rust.

We recognize that you may wish to make a runtime decision to decide the database driver. The Any driver is provided for that purpose.

Example

// connect to SQLite
let conn = AnyConnection::connect("sqlite://file.db").await?;

// connect to Postgres, no code change
// required, decided by the scheme of the URI
let conn = AnyConnection::connect("postgres://localhost/sqlx").await?;

Traits