Try out some basic sqlite stuff
This commit is contained in:
parent
14c5a29aa4
commit
9a956785ef
3 changed files with 46 additions and 2 deletions
30
src/TaskMachine/Database.hs
Normal file
30
src/TaskMachine/Database.hs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module TaskMachine.Database
|
||||
( initializeNewDB
|
||||
) where
|
||||
|
||||
--import qualified Data.Text as T
|
||||
import qualified Database.SQLite.Simple as DB
|
||||
|
||||
initializeNewDB :: DB.Connection -> IO ()
|
||||
initializeNewDB c = do
|
||||
DB.execute_ c createTaskTable
|
||||
DB.execute_ c createVersionTable
|
||||
DB.execute c fillVersionTable (DB.Only (1 :: Integer))
|
||||
where
|
||||
createTaskTable =
|
||||
"CREATE TABLE IF NOT EXISTS tasks (\
|
||||
\ id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\
|
||||
\ deadline TEXT,\
|
||||
\ formula TEXT,\
|
||||
\ description TEXT NOT NULL,\
|
||||
\ repetitions_total INTEGER NOT NULL DEFAULT 1,\
|
||||
\ repetitions_done INTEGER NOT NULL DEFAULT 0\
|
||||
\)"
|
||||
createVersionTable =
|
||||
"CREATE TABLE version (\
|
||||
\ version_number INTEGER\
|
||||
\)"
|
||||
fillVersionTable =
|
||||
"INSERT INTO version (version_number) VALUES (?)"
|
||||
Loading…
Add table
Add a link
Reference in a new issue