4 //use rusqlite::types::ToSql;
5 //use rusqlite::{Connection, Result, NO_PARAMS};
7 const CURRENT_DB_VERSION
: u32 = 1;
10 pub sqlite_con
: rusqlite
::Connection
14 fn new() -> Connection
{
16 // TODO: use a constant in consts module.
17 let data_dir
= Path
::new("data");
19 if !data_dir
.exists() {
20 fs
::DirBuilder
::new().create(data_dir
).unwrap();
23 Connection
{ sqlite_con
: rusqlite
::Connection
::open(data_dir
.join("recipes.sqlite")).unwrap() }
27 pub fn create_or_update() {
28 let connection
= Connection
::new();
30 // let mut stmt = connection.sqlite_con.prepare("SELECT * FROM versions ORDER BY date").unwrap();
32 //let mut stmt = connection.sqlite_con..prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='versions'").unwrap();
33 connection
.sqlite_con
.query_row(
34 "SELECT name FROM sqlite_master WHERE type='table' AND name='versions'",
36 |row
| Ok(dbg!("test"))