Module butane_core::db
source · Expand description
Types, traits, and methods for interacting with a database.
The different ways of referring to a database handle may present some initial confusion.
ConnectionMethods
is a trait containing the methods available on a database connection or a transaction. Most methods on a DataObject or a Query require an implementation ofConnectionMethods
.BackendConnection
is a trait representing a direct connection to a database backend. It is a superset ofConnectionMethods
and also includes the ability to create a transaction.Transaction
is a struct representing a database transaction. It implementsConnectionMethods
.Connection
is a convenience struct containing a boxedBackendConnection
. It cannot do anything other than what aBackendConnection
can do, but allows using a single concrete type that is not tied to a particular database backend. It is returned by theconnect
method.
Structs
- Represents a database column. Most users do not need to use this directly.
- Database connection. May be a connection to any type of database as it is a boxed abstraction over a specific connection.
- Connection specification. Contains the name of a database backend and the backend-specific connection string. See connect to make a Connection from a
ConnectionSpec
. - Database transaction.
Traits
- Database backend. A boxed implementation can be returned by name via get_backend.
- Database connection.
- Backend-specific row abstraction. Only implementors of new backends need use this trait directly.
- Abstraction of rows returned from a query. Most users do not need to deal with this directly and should use the
query!
macro or Query type. - Methods available on a database connection. Most users do not need to call these methods directly and will instead use methods on DataObject or the
query!
macro. This trait is implemented by both database connections and transactions.
Functions
- Connect to a database. For non-boxed connections, see individual Backend implementations.
- Find a backend by name.