Skip to main content

Module db

Module db 

Source
Expand description

Database connectors.

The top-level functions (connect, connect_verified, ping, close) target relational databases via sqlx’s driver-agnostic AnyPool and are compiled only when the sql (or a driver) feature is active.

NoSQL and other backends live in sub-modules gated by their own features:

  • mongo — MongoDB client connector (mongodb feature)

Modules§

mongo
MongoDB client connector.

Functions§

close
Gracefully close a pool, waiting for in-flight connections to be released. Call this during shutdown so the database sees a clean disconnect.
connect
Connect to a relational database described by config, returning a ready connection pool.
connect_verified
Connect and immediately verify the database answers, so misconfiguration fails fast at startup rather than on the first query.
ping
Health-check an existing pool by issuing SELECT 1. Works across all supported relational backends.