Learn about the Shuttle Shared Database resource.
shuttle-shared-db
dependency.
Each type of shareable database is behind its own feature flag and macro attribute path.
Engine | Feature flag | Attribute path |
---|---|---|
Postgres | postgres | shuttle_shared_db::Postgres |
Feature flag | Type declaration | Description |
---|---|---|
String | The connection string including username and password (example) | |
sqlx (with rustls) or sqlx-native-tls | sqlx::PgPool | An sqlx connection pool (example) |
diesel-async | diesel_async::AsyncPgConnection | An async diesel connection |
diesel-async-bb8 | diesel_bb8::Pool<diesel_async::AsyncPgConnection> | A bb8 connection pool |
diesel-async-deadpool | diesel_deadpool::Pool<diesel_async::AsyncPgConnection> | A deadpool connection pool |
opendal-postgres | opendal::Operator | An OpenDAL Operator key-value storage interface |
opendal-postgres | shuttle_shared_db::SerdeJsonOperator | A wrapper over Operator with interface for serde types (example) |
sqlx
compile-time checked macros. Use cargo sqlx prepare
to enable offline building.Parameter | Type | Description |
---|---|---|
local_uri | &str | If specified, on local runs, use this database instead of starting a Docker container for it |
Secrets.toml
using string interpolation.
To insert the PASSWORD
secret, pass it in like this:
Secrets.dev.toml
, you need to set the same secret in Secrets.toml
to a empty string so that this step does not crash in deployment.local_uri
, then cargo-shuttle will attempt to spin up a Docker container and launch the database inside of it.
For this to succeed, you must have Docker installed and you must also have started the Docker engine. If you have not used Docker
before, the easiest way is to install the desktop app and then launch it in order to start
the Docker engine.
#[shuttle_shared_db::Postgres]
attribute macro to provision a shared Postgres database,
which can be accessed with an sqlx Pool.