module Core.SQLite where import Core.Types import Control.Monad.Reader (ask, lift, liftIO) import Data.ByteString as B import Database.SQLite.Simple import Database.SQLite.Simple.FromRow import qualified Data.Text as T main :: String -> IO () main db = do conn <- open db execute_ conn "CREATE TABLE IF NOT EXISTS pws\ \ (link TEXT PRIMARY KEY,\ \ secret TEXT,\ \ nonce TEXT,\ \ date DATETIME DEFAULT CURRENT_TIMESTAMP,\ \ life INT,\ \ views INT,\ \ maxViews INT)" close conn dbPath :: PurrAction String dbPath = lift ask >>= (\a -> return $ dbFile a) encKey :: IO ByteString encKey = B.readFile "./data/key" confLinkLength :: PurrAction Int confLinkLength = lift ask >>= (\a -> return $ linkLength a)