pub enum Drivers {
Postgres,
SQLite,
MySQL,
}Expand description
Supported database driver types.
This enum represents the different database backends that Bottle ORM can work with. The driver type is automatically detected from the connection URL and used to generate appropriate SQL syntax for each database system.
§Variants
Postgres- PostgreSQL database (9.5+)SQLite- SQLite database (3.x)MySQL- MySQL or MariaDB database (5.7+/10.2+)
§SQL Dialect Differences
Different drivers use different SQL syntax:
-
Placeholders:
- PostgreSQL:
$1, $2, $3(numbered) - SQLite/MySQL:
?, ?, ?(positional)
- PostgreSQL:
-
Type Casting:
- PostgreSQL:
$1::UUID,$2::TIMESTAMPTZ - SQLite/MySQL: Automatic type inference
- PostgreSQL:
-
Schema Queries:
- PostgreSQL:
information_schematables - SQLite:
sqlite_mastersystem table - MySQL:
information_schematables
- PostgreSQL:
§Example
ⓘ
match db.driver {
Drivers::Postgres => println!("Using PostgreSQL"),
Drivers::SQLite => println!("Using SQLite"),
Drivers::MySQL => println!("Using MySQL"),
}Variants§
Postgres
PostgreSQL driver.
Used for PostgreSQL databases. Supports advanced features like:
- UUID native type
- JSONB for JSON data
- Array types
- Full-text search
- Advanced indexing (GiST, GIN, etc.)
SQLite
SQLite driver.
Used for SQLite databases (both in-memory and file-based). Characteristics:
- Lightweight and embedded
- Single-file database
- Limited concurrent write support
- Good for development and small applications
MySQL
MySQL driver.
Used for MySQL and MariaDB databases. Features:
- Wide compatibility
- Good performance for read-heavy workloads
- Mature ecosystem
- ACID compliance (with InnoDB)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Drivers
impl RefUnwindSafe for Drivers
impl Send for Drivers
impl Sync for Drivers
impl Unpin for Drivers
impl UnwindSafe for Drivers
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more