Permalink
Browse files

Run the first SQL query

  • Loading branch information...
adomokos committed Nov 30, 2017
1 parent ff40249 commit 78a597e2c348abe751178812367f260fde69edb6
Showing with 40 additions and 4 deletions.
  1. +27 −2 app/Main.hs
  2. +6 −0 hashmir.cabal
  3. +3 −0 package.yaml
  4. +4 −2 stack.yaml
View
@@ -1,6 +1,31 @@
{-#LANGUAGE TemplateHaskell #-}
{-#LANGUAGE QuasiQuotes #-}
module Main where
import Lib
import Database.YeshQL
import Database.HDBC.MySQL
[yesh|
-- name:countClientSQL :: (Int)
SELECT count(id) FROM clients;
|]
getConn :: IO Connection
getConn = do
connectMySQL defaultMySQLConnectInfo {
mysqlHost = "localhost",
mysqlDatabase = "hashmir_test",
mysqlUser = "hashmir_user",
mysqlPassword = "shei7AnganeihaeF",
mysqlUnixSocket = "/tmp/mysql.sock"
}
countClient :: IO ()
countClient = do
conn <- getConn
Just (clientCount) <- countClientSQL conn
putStrLn $ "There are " ++ show clientCount ++ " records."
main :: IO ()
main = someFunc
main = countClient
View
@@ -19,6 +19,9 @@ library
ghc-options: -Wall
build-depends:
base >= 4.7 && < 5
, yeshql
, HDBC
, HDBC-mysql
exposed-modules:
Lib
other-modules:
@@ -32,5 +35,8 @@ executable hashmir-exe
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >= 4.7 && < 5
, yeshql
, HDBC
, HDBC-mysql
, hashmir
default-language: Haskell2010
View
@@ -10,6 +10,9 @@ ghc-options: -Wall
dependencies:
- base >= 4.7 && < 5
- yeshql
- HDBC
- HDBC-mysql
library:
source-dirs: src/
View
@@ -39,7 +39,9 @@ packages:
- .
# Dependency packages to be pulled from upstream that are not in the resolver
# (e.g., acme-missiles-0.3)
extra-deps: []
extra-deps: [
yeshql-3.0.1.3
]
# Override default flag values for local packages and extra-deps
flags: {}
@@ -63,4 +65,4 @@ extra-package-dbs: []
# extra-lib-dirs: [/path/to/dir]
#
# Allow a newer minor version of GHC than the snapshot specifies
# compiler-check: newer-minor
# compiler-check: newer-minor

0 comments on commit 78a597e

Please sign in to comment.