pub trait Connection<'a> {
// Required methods
fn open<T>(path: T) -> Result<Self, MinSqliteWrapperError<'a>>
where Self: Sized,
T: AsRef<Path>;
fn close(self) -> SqlitePrimaryResult;
}Expand description
Specifies the core operations of the SQLite connection.
Required Methods§
Sourcefn open<T>(path: T) -> Result<Self, MinSqliteWrapperError<'a>>
fn open<T>(path: T) -> Result<Self, MinSqliteWrapperError<'a>>
Opens a database and creates a new database connection. If the filename does not exist, it will be created. The file will be opened read/write if possible. If not, the file will be opened read-only.
§Panics
- If the read/write permissions are missing on the database file.
- If the database file isn’t a valid SQLite file or it’s corrupted.
§Usage
let db_path = Path::new(“./example.db”); Database::open(db_path).unwrap();
Sourcefn close(self) -> SqlitePrimaryResult
fn close(self) -> SqlitePrimaryResult
The sqlite3_close() is destructor for the sqlite3 object. Returns SqlitePrimaryResult::Ok if the sqlite3 object is successfully destroyed and all associated resources are deallocated.
§Usage
let db_path = Path::new(“./example.db”); let db = Database::open(db_path).unwrap(); let status = db.close();
if SqlitePrimaryResult::Ok != status { … }