Debian Codegraph @

src/database.rs

raw symbols SCIP
1 //! Traits to represent a database driver.
2 //!
3 //! # Support
4 //!
5 //! ## Tier 1
6 //!
7 //! Tier 1 support can be thought of as "guaranteed to work". Automated testing is setup to
8 //! ensure a high level of stability and functionality.
9 //!
10 //! | Database | Version | Driver |
11 //! | - | - | - |
12 //! | [MariaDB] | 10.1+ | [`mysql`] |
13 //! | [Microsoft SQL Server] | 2019 | [`mssql`] (Pending a full rewrite) |
14 //! | [MySQL] | 5.6, 5.7, 8.0 | [`mysql`] |
15 //! | [PostgreSQL] | 9.5+ | [`postgres`] |
16 //! | [SQLite] | 3.20.1+ | [`sqlite`] |
17 //!
18 //! [MariaDB]: https://mariadb.com/
19 //! [MySQL]: https://www.mysql.com/
20 //! [Microsoft SQL Server]: https://www.microsoft.com/en-us/sql-server
21 //! [PostgreSQL]: https://www.postgresql.org/
22 //! [SQLite]: https://www.sqlite.org/
23 //!
24 //! [`mysql`]: crate::mysql
25 //! [`postgres`]: crate::postgres
26 //! [`mssql`]: crate::mssql
27 //! [`sqlite`]: crate::sqlite
28 //!
29 //! ## Tier 2
30 //!
31 //! Tier 2 support can be thought as "should work". No specific automated testing is done,
32 //! at this time, but there are efforts to ensure compatibility. Tier 2 support also includes
33 //! database distributions that provide protocols that closely match a database from Tier 1.
34 //!
35 //! _No databases are in tier 2 at this time._
36 //!
37 //! # `Any`
38 //!
39 //! Selecting a database driver is, by default, a compile-time decision. SQLx is designed this way
40 //! to take full advantage of the performance and type safety made available by Rust.
41 //!
42 //! We recognize that you may wish to make a runtime decision to decide the database driver. The
43 //! [`Any`](crate::any) driver is provided for that purpose.
44 //!
45 //! ## Example
46 //!
47 //! ```rust,ignore
48 //! // connect to SQLite
49 //! let conn = AnyConnection::connect("sqlite://file.db").await?;
50 //!
51 //! // connect to Postgres, no code change
52 //! // required, decided by the scheme of the URL
53 //! let conn = AnyConnection::connect("postgres://localhost/sqlx").await?;
54 //! ```
55
56 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#;
57
58 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::argumentsrust-analyzer cargo sqlx-core 0.8.3 arguments/::Argumentsrust-analyzer cargo sqlx-core 0.8.3 arguments/Arguments#;
59 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::columnrust-analyzer cargo sqlx-core 0.8.3 column/::Columnrust-analyzer cargo sqlx-core 0.8.3 column/Column#;
60 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::connectionrust-analyzer cargo sqlx-core 0.8.3 connection/::Connectionrust-analyzer cargo sqlx-core 0.8.3 connection/Connection#;
61 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::rowrust-analyzer cargo sqlx-core 0.8.3 row/::Rowrust-analyzer cargo sqlx-core 0.8.3 row/Row#;
62
63 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::statementrust-analyzer cargo sqlx-core 0.8.3 statement/::Statementrust-analyzer cargo sqlx-core 0.8.3 statement/Statement#;
64 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/::TransactionManagerrust-analyzer cargo sqlx-core 0.8.3 transaction/TransactionManager#;
65 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::type_inforust-analyzer cargo sqlx-core 0.8.3 type_info/::TypeInforust-analyzer cargo sqlx-core 0.8.3 type_info/TypeInfo#;
66 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::valuerust-analyzer cargo sqlx-core 0.8.3 value/::{Valuerust-analyzer cargo sqlx-core 0.8.3 value/Value#, ValueRefrust-analyzer cargo sqlx-core 0.8.3 value/ValueRef#};
67
68 /// A database driver.
69 ///
70 /// This trait encapsulates a complete set of traits that implement a driver for a
71 /// specific database (e.g., MySQL, PostgreSQL).
72 pub trait Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#: 'static + Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# {
73 /// The concrete `Connection` implementation for this database.
74 type Connectionrust-analyzer cargo sqlx-core 0.8.3 database/Database#Connection#: Connectionrust-analyzer cargo sqlx-core 0.8.3 connection/Connection#<Databaserust-analyzer cargo sqlx-core 0.8.3 connection/Connection#Database# = Self>;
75
76 /// The concrete `TransactionManager` implementation for this database.
77 type TransactionManagerrust-analyzer cargo sqlx-core 0.8.3 database/Database#TransactionManager#: TransactionManagerrust-analyzer cargo sqlx-core 0.8.3 transaction/TransactionManager#<Databaserust-analyzer cargo sqlx-core 0.8.3 transaction/TransactionManager#Database# = Self>;
78
79 /// The concrete `Row` implementation for this database.
80 type Rowrust-analyzer cargo sqlx-core 0.8.3 database/Database#Row#: Rowrust-analyzer cargo sqlx-core 0.8.3 row/Row#<Databaserust-analyzer cargo sqlx-core 0.8.3 row/Row#Database# = Self>;
81
82 /// The concrete `QueryResult` implementation for this database.
83 type QueryResultrust-analyzer cargo sqlx-core 0.8.3 database/Database#QueryResult#: 'static + Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# + Extendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/Extend#<Self::QueryResultrust-analyzer cargo sqlx-core 0.8.3 database/Database#QueryResult#>;
84
85 /// The concrete `Column` implementation for this database.
86 type Columnrust-analyzer cargo sqlx-core 0.8.3 database/Database#Column#: Columnrust-analyzer cargo sqlx-core 0.8.3 column/Column#<Databaserust-analyzer cargo sqlx-core 0.8.3 column/Column#Database# = Self>;
87
88 /// The concrete `TypeInfo` implementation for this database.
89 type TypeInforust-analyzer cargo sqlx-core 0.8.3 database/Database#TypeInfo#: TypeInforust-analyzer cargo sqlx-core 0.8.3 type_info/TypeInfo#;
90
91 /// The concrete type used to hold an owned copy of the not-yet-decoded value that was
92 /// received from the database.
93 type Valuerust-analyzer cargo sqlx-core 0.8.3 database/Database#Value#: Valuerust-analyzer cargo sqlx-core 0.8.3 value/Value#<Databaserust-analyzer cargo sqlx-core 0.8.3 value/Value#Database# = Self> + 'static;
94 /// The concrete type used to hold a reference to the not-yet-decoded value that has just been
95 /// received from the database.
96 type ValueRefrust-analyzer cargo sqlx-core 0.8.3 database/Database#ValueRef#<'r>: ValueRefrust-analyzer cargo sqlx-core 0.8.3 value/ValueRef#<'r, Databaserust-analyzer cargo sqlx-core 0.8.3 value/ValueRef#Database# = Self>;
97
98 /// The concrete `Arguments` implementation for this database.
99 type Argumentsrust-analyzer cargo sqlx-core 0.8.3 database/Database#Arguments#<'q>: Argumentsrust-analyzer cargo sqlx-core 0.8.3 arguments/Arguments#<'q, Databaserust-analyzer cargo sqlx-core 0.8.3 arguments/Arguments#Database# = Self>;
100 /// The concrete type used as a buffer for arguments while encoding.
101 type ArgumentBufferrust-analyzer cargo sqlx-core 0.8.3 database/Database#ArgumentBuffer#<'q>;
102
103 /// The concrete `Statement` implementation for this database.
104 type Statementrust-analyzer cargo sqlx-core 0.8.3 database/Database#Statement#<'q>: Statementrust-analyzer cargo sqlx-core 0.8.3 statement/Statement#<'q, Databaserust-analyzer cargo sqlx-core 0.8.3 statement/Statement#Database# = Self>;
105
106 /// The display name for this database driver.
107 const NAMErust-analyzer cargo sqlx-core 0.8.3 database/Database#NAME.: &'static str;
108
109 /// The schemes for database URLs that should match this driver.
110 const URL_SCHEMESrust-analyzer cargo sqlx-core 0.8.3 database/Database#URL_SCHEMES.: &'static [&'static str];
111 }
112
113 /// A [`Database`] that maintains a client-side cache of prepared statements.
114 pub trait HasStatementCacherust-analyzer cargo sqlx-core 0.8.3 database/HasStatementCache# {}