HomeServer/src/db.rs

29 lines
507 B
Rust
Raw Normal View History

2023-09-19 08:52:12 +00:00
use std::path::Path;
use anyhow::Result;
use rusqlite::Connection;
pub struct DataBase {
sql: Connection,
}
impl DataBase {
pub async fn new(path: impl AsRef<Path>) -> Result<Self> {
let me = Self {
sql: Connection::open(path)?,
};
me.generate_tables()?;
Ok(me)
}
fn generate_tables(&self) -> Result<()> {
todo!()
}
pub async fn write(&self, device_name: &str, time: u64, watts: f32) -> Result<()> {
todo!()
}
}