addUser function.

This commit is contained in:
Adam C. Baker
2014-09-29 15:52:01 -07:00
committed by Joe Nelson
parent e5c4567166
commit 14fa20f0e6
2 changed files with 16 additions and 6 deletions
+8 -1
View File
@@ -6,6 +6,7 @@ module PgQuery (
getRows,
insert,
upsert,
addUser,
RangedResult(..),
) where
@@ -28,7 +29,7 @@ import Database.HDBC.PostgreSQL
import qualified Network.HTTP.Types.URI as Net
import Types (SqlRow, getRow, sqlRowColumns, sqlRowValues)
import Types (SqlRow(..), getRow, sqlRowColumns, sqlRowValues)
import Debug.Trace
@@ -122,6 +123,12 @@ insert schema table row conn = do
Just m <- fetchRowMap stmt
return m
addUser :: String -> String -> Connection -> IO ()
addUser identity role conn =
insert "dbapi" "auth" (SqlRow [
("id", toSql identity), ("rolname", toSql role)
]) conn >> return ()
upsert :: Schema -> Text -> SqlRow -> Net.Query -> Connection -> IO (M.Map String SqlValue)
upsert schema table row qq conn = do
sql <- populateSql conn $ upsertClause schema table row qq