29 lines
507 B
Rust
29 lines
507 B
Rust
|
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!()
|
||
|
}
|
||
|
}
|