summaryrefslogtreecommitdiff
path: root/haskell/src/SpaceTraders/Database
diff options
context:
space:
mode:
authorJulien Dessaux2023-07-03 21:29:15 +0200
committerJulien Dessaux2023-07-03 21:29:15 +0200
commitb3d57cb6adf1e3f6a8ba7cf1c1553b6fd4acb578 (patch)
tree8f596ee49ad84f320d5950fe5690bee335f930be /haskell/src/SpaceTraders/Database
parentBootstrapped my haskell client (diff)
downloadspacetraders-b3d57cb6adf1e3f6a8ba7cf1c1553b6fd4acb578.tar.gz
spacetraders-b3d57cb6adf1e3f6a8ba7cf1c1553b6fd4acb578.tar.bz2
spacetraders-b3d57cb6adf1e3f6a8ba7cf1c1553b6fd4acb578.zip
[haskell] Implemented contract
Diffstat (limited to '')
-rw-r--r--haskell/src/SpaceTraders/Database/Agents.hs1
-rw-r--r--haskell/src/SpaceTraders/Database/Contracts.hs13
2 files changed, 13 insertions, 1 deletions
diff --git a/haskell/src/SpaceTraders/Database/Agents.hs b/haskell/src/SpaceTraders/Database/Agents.hs
index 5be7389..48cd65b 100644
--- a/haskell/src/SpaceTraders/Database/Agents.hs
+++ b/haskell/src/SpaceTraders/Database/Agents.hs
@@ -1,5 +1,4 @@
{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE QuasiQuotes #-}
module SpaceTraders.Database.Agents
( setAgent
diff --git a/haskell/src/SpaceTraders/Database/Contracts.hs b/haskell/src/SpaceTraders/Database/Contracts.hs
new file mode 100644
index 0000000..1ef5d6d
--- /dev/null
+++ b/haskell/src/SpaceTraders/Database/Contracts.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+module SpaceTraders.Database.Contracts
+ ( addContract
+ ) where
+
+import Data.Aeson
+import qualified Database.SQLite.Simple as S
+
+import SpaceTraders.Model.Contract
+
+addContract :: S.Connection -> Contract -> IO ()
+addContract conn contract = S.execute conn "INSERT INTO contracts(data) VALUES (json(?));" (S.Only (encode contract))