Try out some basic sqlite stuff
This commit is contained in:
parent
14c5a29aa4
commit
9a956785ef
3 changed files with 46 additions and 2 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
import Lib
|
import qualified Database.SQLite.Simple as DB
|
||||||
|
|
||||||
|
import qualified TaskMachine.Database as TMB
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = someFunc
|
main = DB.withConnection "test.db" TMB.initializeNewDB
|
||||||
|
|
|
||||||
12
package.yaml
12
package.yaml
|
|
@ -21,6 +21,18 @@ description: Please see the README on Github at <https://github.com/Garm
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- base >= 4.7 && < 5
|
- base >= 4.7 && < 5
|
||||||
|
- sqlite-simple
|
||||||
|
#- containers
|
||||||
|
#- unordered-containers
|
||||||
|
#- text
|
||||||
|
#- time
|
||||||
|
#- transformers
|
||||||
|
#- async
|
||||||
|
#- aeson
|
||||||
|
#- bytestring
|
||||||
|
#- stm
|
||||||
|
#- megaparsec
|
||||||
|
#- brick
|
||||||
|
|
||||||
library:
|
library:
|
||||||
source-dirs: src
|
source-dirs: src
|
||||||
|
|
|
||||||
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