generated from lucien/actix-react-template
23 lines
587 B
Rust
23 lines
587 B
Rust
use sqlite::{Connection, OpenFlags};
|
|
|
|
pub fn init() -> sqlite::Result<()> {
|
|
let conn = Connection::open_with_flags(
|
|
"./data/data.db",
|
|
OpenFlags::new()
|
|
.with_create()
|
|
.with_read_write()
|
|
)?;
|
|
|
|
conn.execute(
|
|
"CREATE TABLE IF NOT EXISTS articles (
|
|
id INTEGER PRIMARY KEY,
|
|
title TEXT NOT NULL,
|
|
auteur TEXT,
|
|
edited_at DATE_FORMAT('now', '%YYYY-%mm-%dd'),
|
|
published_at DATE_FORMAT('now', '%YYYY-%mm-%dd'),
|
|
content TEXT NOT NULL
|
|
)",
|
|
)?;
|
|
|
|
Ok(())
|
|
}
|