Added database init function

This commit is contained in:
Lukian 2024-12-06 01:00:02 +01:00
parent 6461ebc629
commit 902e96b205
4 changed files with 13 additions and 8 deletions

16
back/src/create_db.rs Normal file
View file

@ -0,0 +1,16 @@
use sqlite::{Connection, State, Error};
pub fn init() -> sqlite::Result<()> {
let conn = Connection::open("./data/data.db")?;
conn.execute(
"CREATE TABLE IF NOT EXISTS articles (
id INTEGER PRIMARY KEY,
title TEXT NOT NULL,
subTitle TEXT,
content TEXT NOT NULL
)",
)?;
Ok(())
}