try to use sql_sessions

This commit is contained in:
pena 2022-02-18 03:24:23 +01:00 committed by Swrup
parent 0d9ffe14d5
commit 93f7e830f0
2 changed files with 20 additions and 3 deletions

View file

@ -9,12 +9,25 @@ let () =
let db = Filename.concat db_root "permap.db"
let db_uri = Format.sprintf "sqlite3://%s" db
let random_state = Random.State.make_self_init ()
module Db =
( val Caqti_blocking.connect (Uri.of_string ("sqlite3://" ^ db))
|> Caqti_blocking.or_fail )
(val Caqti_blocking.connect (Uri.of_string db_uri) |> Caqti_blocking.or_fail)
(* TODO do image validation: length and MIME types with conan*)
(* TODO do the same for text input: check length, forbidden chars and have a forbidden words filter*)
let is_valid_image _content = true
let () =
let query =
Caqti_request.exec Caqti_type.unit
"CREATE TABLE IF NOT EXISTS dream_session (id TEXT PRIMARY KEY, label \
TEXT NOT NULL, expires_at REAL NOT NULL, payload TEXT NOT NULL);"
in
match Db.exec query () with
| Ok () -> ()
| Error _e ->
Format.eprintf "db error@\n";
exit 1