Skip to main content

Connection

Struct Connection 

Source
pub struct Connection { /* private fields */ }

Implementations§

Source§

impl Connection

Source§

impl Connection

Source

pub fn prepare( self: &Arc<Connection>, sql: impl AsRef<str>, ) -> Result<Statement>

Source

pub fn query( self: &Arc<Connection>, sql: impl AsRef<str>, ) -> Result<Option<Statement>>

Source

pub fn query_runner<'a>( self: &'a Arc<Connection>, sql: &'a [u8], ) -> QueryRunner<'a>

Source

pub fn execute(self: &Arc<Connection>, sql: impl AsRef<str>) -> Result<()>

Execute will run a query from start to finish taking ownership of I/O because it will run pending I/Os if it didn’t finish. TODO: make this api async

Source

pub fn wal_frame_count(&self) -> Result<u64>

Source

pub fn wal_get_frame( &self, frame_no: u32, p_frame: *mut u8, frame_len: u32, ) -> Result<Arc<Completion>>

Source

pub fn cacheflush(&self) -> Result<PagerCacheflushStatus>

Flush dirty pages to disk. This will write the dirty pages to the WAL and then fsync the WAL. If the WAL size is over the checkpoint threshold, it will checkpoint the WAL to the database file and then fsync the database file.

Source

pub fn clear_page_cache(&self) -> Result<()>

Source

pub fn checkpoint(&self) -> Result<CheckpointResult>

Source

pub fn checkpoint_truncate(&self) -> Result<CheckpointResult>

Run a checkpoint in TRUNCATE mode (resets the WAL file to empty).

Source

pub fn close(&self) -> Result<()>

Close a connection, checkpointing and truncating the WAL so the database file is self-contained. Idempotent: a second call is a no-op.

Source

pub fn last_insert_rowid(&self) -> i64

Source

pub fn set_changes(&self, nchange: i64)

Source

pub fn changes(&self) -> i64

Return the number of rows changed by the most recent DML statement.

Mirrors sqlite3_changes() semantics: DDL and BEGIN/COMMIT/ROLLBACK return 0. The count is updated by Connection::set_changes when a write transaction commits.

Source

pub fn total_changes(&self) -> i64

Source

pub fn get_cache_size(&self) -> i32

Source

pub fn set_cache_size(&self, size: i32)

Source

pub fn open_new( &self, path: &str, vfs: &str, ) -> Result<(Arc<dyn IO>, Arc<Database>)>

Source

pub fn list_vfs(&self) -> Vec<String>

Source

pub fn get_auto_commit(&self) -> bool

Source

pub fn parse_schema_rows(self: &Arc<Connection>) -> Result<()>

Source

pub fn load_persistent_stats(self: &Arc<Connection>) -> Result<()>

Load persisted ANALYZE statistics (sqlite_stat1) into the schema’s in-memory side-map. No-op (bit-for-bit unchanged) when sqlite_stat1 does not exist, i.e. for databases that have never been analyzed.

Source

pub fn pragma_query( self: &Arc<Connection>, pragma_name: &str, ) -> Result<Vec<Vec<Value>>>

Query the current rows/values of pragma_name.

Source

pub fn pragma_update<V: Display>( self: &Arc<Connection>, pragma_name: &str, pragma_value: V, ) -> Result<Vec<Vec<Value>>>

Set a new value to pragma_name.

Some pragmas will return the updated value which cannot be retrieved with this method.

Source

pub fn pragma<V: Display>( self: &Arc<Connection>, pragma_name: &str, pragma_value: V, ) -> Result<Vec<Vec<Value>>>

Query the current value(s) of pragma_name associated to pragma_value.

This method can be used with query-only pragmas which need an argument (e.g. table_info('one_tbl')) or pragmas which returns value(s) (e.g. integrity_check).

Trait Implementations§

Source§

impl Drop for Connection

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more