diff options
| author | Paul Buetow <paul@buetow.org> | 2011-10-15 23:52:02 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2011-10-15 23:52:02 +0200 |
| commit | 74bbc61e4dd44569d7f6b5eaa1b97cd00685cfc9 (patch) | |
| tree | a66d8a0062543507e4e27f74a6e8d94034caee26 /HsBot/Base/Database.hs | |
| parent | bbb1bc28fe10f1b1fdc433ecf9502e2821f024f8 (diff) | |
some testing stuff
Diffstat (limited to 'HsBot/Base/Database.hs')
| -rw-r--r-- | HsBot/Base/Database.hs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/HsBot/Base/Database.hs b/HsBot/Base/Database.hs index ae633e8..46a16d4 100644 --- a/HsBot/Base/Database.hs +++ b/HsBot/Base/Database.hs @@ -6,17 +6,21 @@ import qualified Database.HSQL.MySQL as MySQL import qualified Database.HSQL.Types as Types data Database = Database { - connection :: IO Types.Connection - } + connection :: IO Types.Connection, + connectionString :: String + } -databaseMake conf = Database { - connection = databaseMakeConnection conf - } +instance Show Database where + show database = show $ connectionString database -databaseMakeConnection :: Conf -> IO Types.Connection -databaseMakeConnection conf = do +databaseMake :: Conf -> IO Database +databaseMake conf = do dbHost <- get "dbHost" conf dbUser <- get "dbUser" conf dbSchema <- get "dbSchema" conf dbPass <- get "dbPass" conf - MySQL.connect dbHost dbUser dbSchema dbPass + return $ Database { + connection = MySQL.connect dbHost dbUser dbSchema dbPass, + connectionString = dbHost ++ " " ++ dbUser ++ " " ++ dbSchema ++ " " ++ dbPass + } + |
