[−][src]Struct rsqlite::Database
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]
R: Collectable,
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]
&self,
sql: &str,
params: impl Bindable,
iterable: impl Iterable<(), T>
) -> Result<()>
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,