pub struct Database {
pub db: *mut sqlite3,
}
Fields§
§db: *mut sqlite3
Implementations§
Source§impl Database
impl Database
Sourcepub fn open(path: &str) -> Result<Database>
pub fn open(path: &str) -> Result<Database>
open an existing sqlite3 database or create a new one.
let database = Database::open(":memory:")?;
Sourcepub fn open_with_flags(path: &str, flags: c_int) -> Result<Database>
pub fn open_with_flags(path: &str, flags: c_int) -> Result<Database>
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
)?;
Sourcepub fn prepare(&self, sql: &str) -> Result<Statement<'_>>
pub fn prepare(&self, sql: &str) -> Result<Statement<'_>>
prepare a query to be executed
let statement = database.prepare("select 1+2;")?;
Sourcepub fn execute(&self, sql: &str, params: impl Bindable) -> Result<()>
pub fn execute(&self, sql: &str, params: impl Bindable) -> Result<()>
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()
.
Sourcepub fn collect<R>(&self, sql: &str, params: impl Bindable) -> Result<R>where
R: Collectable,
pub fn collect<R>(&self, sql: &str, params: impl Bindable) -> Result<R>where
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;", ())?;
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Database
impl RefUnwindSafe for Database
impl !Send for Database
impl !Sync for Database
impl Unpin for Database
impl UnwindSafe for Database
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