pub struct Connection { /* private fields */ }Expand description
A database connection. Supports reading (query) and writing (execute),
over a file or in memory.
Implementations§
Source§impl Connection
impl Connection
Sourcepub fn open_vfs(vfs: &dyn Vfs, path: &str) -> Result<Connection>
pub fn open_vfs(vfs: &dyn Vfs, path: &str) -> Result<Connection>
Open an existing database for reading and writing through vfs. Creates
(and recovers from) a <path>-journal companion file.
Sourcepub fn open_readonly_vfs(vfs: &dyn Vfs, path: &str) -> Result<Connection>
pub fn open_readonly_vfs(vfs: &dyn Vfs, path: &str) -> Result<Connection>
Open an existing database read-only through vfs. If a <path>-wal file
is present, its committed frames are overlaid so WAL-mode databases read
correctly.
Sourcepub fn create_vfs(
vfs: &dyn Vfs,
path: &str,
page_size: u32,
) -> Result<Connection>
pub fn create_vfs( vfs: &dyn Vfs, path: &str, page_size: u32, ) -> Result<Connection>
Create a new, empty database through vfs.
Sourcepub fn open(path: &str) -> Result<Connection>
Available on crate feature std only.
pub fn open(path: &str) -> Result<Connection>
std only.Open an existing database file for reading and writing (requires std).
Sourcepub fn open_readonly(path: &str) -> Result<Connection>
Available on crate feature std only.
pub fn open_readonly(path: &str) -> Result<Connection>
std only.Open an existing database file read-only (requires std).
Sourcepub fn create(path: &str) -> Result<Connection>
Available on crate feature std only.
pub fn create(path: &str) -> Result<Connection>
std only.Create a new database file with the default 4096-byte page size (std).
Sourcepub fn open_memory() -> Result<Connection>
pub fn open_memory() -> Result<Connection>
Create a fresh in-memory database (:memory:), always available.
Sourcepub fn query(&self, sql: &str) -> Result<QueryResult>
pub fn query(&self, sql: &str) -> Result<QueryResult>
Run a single SELECT and return all rows.
Sourcepub fn query_params(&self, sql: &str, params: &Params) -> Result<QueryResult>
pub fn query_params(&self, sql: &str, params: &Params) -> Result<QueryResult>
Like query but with bound parameters.
Trait Implementations§
Source§impl Subqueries for Connection
impl Subqueries for Connection
Source§fn scalar(&self, select: &Select, outer: &EvalCtx<'_>) -> Result<Value>
fn scalar(&self, select: &Select, outer: &EvalCtx<'_>) -> Result<Value>
First column of the first row (NULL if no rows) — a scalar subquery. The
enclosing row context
outer is made available so correlated subqueries
can resolve outer columns.Source§fn column(&self, select: &Select, outer: &EvalCtx<'_>) -> Result<Vec<Value>>
fn column(&self, select: &Select, outer: &EvalCtx<'_>) -> Result<Vec<Value>>
First column of every row — the candidate set for
IN (SELECT …).Auto Trait Implementations§
impl !Freeze for Connection
impl !RefUnwindSafe for Connection
impl !Send for Connection
impl !Sync for Connection
impl !UnwindSafe for Connection
impl Unpin for Connection
impl UnsafeUnpin for Connection
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