Open (or create) the database at `db_path`. Pass `":memory:"` for an in-memory database.
(db_path: &str)
| 23 | /// Open (or create) the database at `db_path`. |
| 24 | /// Pass `":memory:"` for an in-memory database. |
| 25 | pub fn new(db_path: &str) -> GraphBitResult<Self> { |
| 26 | let conn = rusqlite::Connection::open(db_path)?; |
| 27 | // Enable foreign key enforcement (must be set per-connection). |
| 28 | conn.execute("PRAGMA foreign_keys = ON", [])?; |
| 29 | let store = Self { |
| 30 | conn: Arc::new(Mutex::new(conn)), |
| 31 | }; |
| 32 | store.init_schema_sync()?; |
| 33 | Ok(store) |
| 34 | } |
| 35 | |
| 36 | /// Create the required tables if they do not already exist. |
| 37 | fn init_schema_sync(&self) -> GraphBitResult<()> { |
nothing calls this directly
no test coverage detected