Skip to content

Commit

Permalink
Fetching done - Paulos correction
Browse files Browse the repository at this point in the history
  • Loading branch information
Franklin Antony authored and Franklin Antony committed Dec 7, 2020
1 parent 46609b4 commit 9c64bb8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ main = do
let converRes = sqlRowToString res
mapM_ putStrLn converRes
putStrLn "\n****************"
sqlValue <- getUnprocessedSQLHolidays conn
print $ show sqlValue
print "Done!"
putStrLn "\n****************"
putStrLn $ "Number of rows is " ++ show (length res)


Expand Down
16 changes: 16 additions & 0 deletions src/Database.hs
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,20 @@ savecountriesRecord record conn = do
sqlRowToString :: [[SqlValue]] -> [String]
sqlRowToString xs = map (fromSql :: SqlValue -> String) (concat xs)

-- |Method to retrieve all the SQLs on the database.
getUnprocessedSQLHolidays :: Connection -> IO [(String, String, String)]
getUnprocessedSQLHolidays conn = do
res <- quickQuery' conn "SELECT date, localName, name FROM holidays" []
return $ map ( \xs -> ( fromSql (xs!!0), fromSql (xs!!1), fromSql (xs!!2) )) res

getUnprocessedSQLCountries :: Connection -> IO [(String, Bool)]
getUnprocessedSQLCountries conn = do
res <- quickQuery' conn "SELECT countryCode, global FROM countries" []
return $ map ( \xs -> ( fromSql (xs!!0), fromSql (xs!!1) )) res

getUnprocessedSQLCH :: Connection -> IO [(String, String)]
getUnprocessedSQLCH conn = do
res <- quickQuery' conn "SELECT countryCode, localName FROM country_holidays" []
return $ map ( \xs -> ( fromSql (xs!!0), fromSql (xs!!1) )) res


0 comments on commit 9c64bb8

Please sign in to comment.