summaryrefslogtreecommitdiff
path: root/haskell/src/SpaceTraders/Database
diff options
context:
space:
mode:
authorJulien Dessaux2023-07-04 19:37:50 +0200
committerJulien Dessaux2023-07-04 19:37:50 +0200
commit78c5467c4ac39869314c686d1d026482e7b3fd8f (patch)
tree154bc89cd8f9ea87e93d7d638e41f6557daddf22 /haskell/src/SpaceTraders/Database
parent[haskell] Implemented contract (diff)
downloadspacetraders-78c5467c4ac39869314c686d1d026482e7b3fd8f.tar.gz
spacetraders-78c5467c4ac39869314c686d1d026482e7b3fd8f.tar.bz2
spacetraders-78c5467c4ac39869314c686d1d026482e7b3fd8f.zip
[haskell] Implemented ship
Diffstat (limited to 'haskell/src/SpaceTraders/Database')
-rw-r--r--haskell/src/SpaceTraders/Database/Ships.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/haskell/src/SpaceTraders/Database/Ships.hs b/haskell/src/SpaceTraders/Database/Ships.hs
new file mode 100644
index 0000000..81c422d
--- /dev/null
+++ b/haskell/src/SpaceTraders/Database/Ships.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+module SpaceTraders.Database.Ships
+ ( addShip
+ ) where
+
+import Data.Aeson
+import qualified Database.SQLite.Simple as S
+
+import SpaceTraders.Model.Ship
+
+addShip :: S.Connection -> Ship -> IO ()
+addShip conn ship = S.execute conn "INSERT INTO ships(data) VALUES (json(?));" (S.Only (encode ship))