use std::path::Path; use rusqlite::{Connection, Result}; pub fn init() -> Result<()> { // Check if the database file exists, and create it if it doesn't if !Path::new("db.sqlite3").exists() { let db = Connection::open("db.sqlite3")?; match db.execute( "CREATE TABLE IF NOT EXISTS sessions ( state TEXT NOT NULL, access_token TEXT NOT NULL, refresh_token TEXT NOT NULL, last_validated TIMESTAMP DEFAULT CURRENT_TIMESTAMP, UNIQUE(state, access_token) )", [], ) { Ok(_) => println!("Table 'sessions' created successfully."), Err(e) => println!("Error creating table 'sessions': {}", e), }; } Ok(()) }