Paste: Weird type errors
Author: | vegai |
Mode: | haskell |
Date: | Fri, 25 Sep 2009 11:55:55 |
Plain Text |
module Main where
import Database.HDBC.Sqlite3 (connectSqlite3)
import Codec.Compression.GZip (compress)
import Database.HDBC (execute, prepare, SqlValue(..))
import System.Directory (getDirectoryContents)
import System.FilePath.Posix (takeExtension, joinPath)
import qualified Data.ByteString as BS
dbfile = "/home/vegai/dbdump/xml.db"
xml_dir = "/home/vegai/dbdump/outgoing"
stmt = "INSERT INTO xmls VALUES ( ?, ? )"
writeRow db prepared_stmt file = writeRow' (takeExtension file)
where writeRow' ".xml" =
do contents <- BS.readFile expandedFile
compressedContents <- compress contents
execute prepared_stmt [ SqlString file, SqlByteString compressedContents ]
return ()
writeRow' _ = return ()
expandedFile = joinPath [xml_dir, file]
main =
do db <- connectSqlite3 dbfile
files <- getDirectoryContents xml_dir
prepared_stmt <- prepare db stmt
mapM_ (writeRow db prepared_stmt) files
return ()
New Annotation