[][src]Struct rsqlite::Database

pub struct Database {
    pub db: *mut sqlite3,
}

Fields

db: *mut sqlite3

Implementations

impl Database[src]

pub fn open(path: &str) -> Result<Database>[src]

open an existing sqlite3 database or create a new one.

let database = Database::open(":memory:")?;

pub fn open_with_flags(path: &str, flags: c_int) -> Result<Database>[src]

open a sqlite3 database with explicit flags

use sqlite3_sys as ffi;

let database = Database::open_with_flags(
    ":memory:",
    ffi::SQLITE_OPEN_CREATE | ffi::SQLITE_OPEN_READWRITE
)?;

pub fn prepare(&self, sql: &str) -> Result<Statement<'_>>[src]

prepare a query to be executed

let statement = database.prepare("select 1+2;")?;

pub fn execute(&self, sql: &str, params: impl Bindable) -> Result<()>[src]

Execute an sqlite query.

It is expected that the query does to returns any data, if you need to return data, you should use .query().

pub fn collect<R>(&self, sql: &str, params: impl Bindable) -> Result<R> where
    R: Collectable
[src]

Execute a query and collect the results.

Your query must return the same column count as type R If the column index is out of range, you will get Err(SQLITE_RANGE)

let result : (i32, String, f64) = database.collect("select 100, 'hello', 3.14;", ())?;

pub fn for_each<T>(
    &self,
    sql: &str,
    params: impl Bindable,
    iterable: impl Iterable<(), T>
) -> Result<()>
[src]

for_each iterates over multile rows of data using a colusure

let mut sum = 0;
database.for_each("select 2 union select 3", (), |x: i32| { sum += x; })?;
// sum is 5

Trait Implementations

impl Drop for Database[src]

fn drop(&mut self)[src]

closes the *mut sqlite3 handle on Drop

Auto Trait Implementations

impl RefUnwindSafe for Database

impl !Send for Database

impl !Sync for Database

impl Unpin for Database

impl UnwindSafe for Database

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.