diff options
author | Melody Horn <melody@boringcactus.com> | 2021-06-29 22:44:11 -0600 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-06-29 22:44:11 -0600 |
commit | 9829bbfcd57c57e237c6aacb96a78d0b9f5bab68 (patch) | |
tree | 43dc643d7b592d9abc4c5f89121e249ccb597d7d /src/db/backend | |
parent | 9dd7f2256a82f95096d928aaef70d15603152ebc (diff) | |
download | tosin-9829bbfcd57c57e237c6aacb96a78d0b9f5bab68.tar.gz tosin-9829bbfcd57c57e237c6aacb96a78d0b9f5bab68.zip |
lol no generics
Diffstat (limited to 'src/db/backend')
-rw-r--r-- | src/db/backend/mod.rs | 7 | ||||
-rw-r--r-- | src/db/backend/sqlite.rs | 22 |
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", + } + } +} |