Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: a29d72f7b9
Fetching contributors…

Cannot retrieve contributors at this time

file 24 lines (19 sloc) 0.696 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

module Sqlexpr = Sqlexpr_sqlite.Make(Sqlexpr_concurrency.Id)
module S = Sqlexpr

let init_db db =
  S.execute db
    sqlinit"CREATE TABLE IF NOT EXISTS users(
id INTEGER PRIMARY KEY,
login TEXT UNIQUE,
password TEXT NON NULL,
name TEXT,
email TEXT
);"

let fold_users db f acc =
  S.fold db f acc sqlc"SELECT @s{login}, @s{password}, @s?{email} FROM users"

let insert_user db ~login ~password ?name ?email () =
  S.insert db
    sqlc"INSERT INTO users(login, password, name, email)
VALUES(%s, %s, %s?, %s?)"
    login password name email

let auto_init_db, check_db, auto_check_db = sql_check"sqlite"
Something went wrong with that request. Please try again.