aboutsummaryrefslogtreecommitdiff
path: root/src/db/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/backend')
-rw-r--r--src/db/backend/mod.rs7
-rw-r--r--src/db/backend/sqlite.rs22
2 files changed, 29 insertions, 0 deletions
diff --git a/src/db/backend/mod.rs b/src/db/backend/mod.rs
new file mode 100644
index 0000000..b266f1e
--- /dev/null
+++ b/src/db/backend/mod.rs
@@ -0,0 +1,7 @@
+#[cfg(feature = "sqlite")]
+mod sqlite;
+#[cfg(feature = "sqlite")]
+pub use sqlite::*;
+
+#[cfg(not(feature = "sqlite"))]
+compile_error!("pick a backend pls");
diff --git a/src/db/backend/sqlite.rs b/src/db/backend/sqlite.rs
new file mode 100644
index 0000000..002d0d3
--- /dev/null
+++ b/src/db/backend/sqlite.rs
@@ -0,0 +1,22 @@
+use diesel::connection::Connection as _;
+
+pub use barrel::backend::Sqlite as SqlGenerator;
+pub use diesel::sqlite::SqliteConnection as Connection;
+
+pub struct Database {
+ pub db_file: &'static str,
+}
+
+impl Database {
+ pub fn connect(&self) -> diesel::ConnectionResult<Connection> {
+ Connection::establish(self.db_file)
+ }
+}
+
+impl Default for Database {
+ fn default() -> Self {
+ Self {
+ db_file: "db.sqlite3",
+ }
+ }
+}