-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
As of 0.3
use sqlx::Connect;
let mut conn = PgConnection::connect("postgres://user:pass@localhost/database?sslmode=require");
Proposal
let options = ConnectOptions::new()
.host("localhost")
.port(5432)
.username("user")
.password("pass")
.param("sslmode", "require");
let mut conn = PgConnection::connect(options).await?;
let mut conn = options.connect().await?;
let pool = PgPool::new(options).await?;
let pool = PgPool::builder().build(options).await?;
- Introduce
ConnectOptions
- Implement
TryFrom<&str>
forConnectOptions
to parse URI and DSN connection strings - Pool and Connection construction now take
O: TryInto<ConnectOptions>
- The
url
crate should not be used for parsing; in particular, a schema should not be a required piece
Additional ideas:
- Introduce database-specific option extension traits to for parameters. E.g..
PgConnectOptionsExt
would provide assl_mode
method to set thesslmode
parameter.