haskelldb-0.9: ContentsIndex
Database.HaskellDB.Sql
Portabilitynon-portable
Stabilityexperimental
Maintainerdp03-7@mdstud.chalmers.se
Contents
Type Declarations
Function Declarations
Description

Transform a PrimQuery (relational expression) to SQL and pretty print SQL

$Revision: 1.22 $

Synopsis
data SqlSelect
= SqlSelect {
options :: [String]
attrs :: [(Attribute, String)]
tables :: [(TableName, SqlSelect)]
criteria :: [String]
groupby :: [String]
orderby :: [PrimExpr]
limit :: [String]
}
| SqlBin String SqlSelect SqlSelect
| SqlTable TableName
| SqlEmpty
data SqlUpdate = SqlUpdate TableName [String] [String]
data SqlDelete = SqlDelete TableName [String]
data SqlInsert
= SqlInsert TableName [(Attribute, String)]
| SqlInsertQuery TableName SqlSelect
toSql :: PrimQuery -> SqlSelect
ppSql :: SqlSelect -> Doc
toUpdate :: TableName -> [PrimExpr] -> Assoc -> SqlUpdate
ppUpdate :: SqlUpdate -> Doc
toDelete :: TableName -> [PrimExpr] -> SqlDelete
ppDelete :: SqlDelete -> Doc
toInsert :: TableName -> Assoc -> SqlInsert
ppInsert :: SqlInsert -> Doc
toInsertQuery :: TableName -> PrimQuery -> SqlInsert
toCreateDB :: String -> SqlCreate
toCreateTable :: TableName -> [(Attribute, FieldDesc)] -> SqlCreate
ppCreate :: SqlCreate -> Doc
toDropDB :: String -> SqlDrop
toDropTable :: TableName -> SqlDrop
ppDrop :: SqlDrop -> Doc
Type Declarations
data SqlSelect
Data type representing the SQL SELECT statement. Can be created with the toSql function', and pretty printed with the ppSql function.
Constructors
SqlSelect
options :: [String]
attrs :: [(Attribute, String)]
tables :: [(TableName, SqlSelect)]
criteria :: [String]
groupby :: [String]
orderby :: [PrimExpr]
limit :: [String]
SqlBin String SqlSelect SqlSelect
SqlTable TableNameSelect a whole table named TableName.
SqlEmptyEmpty select.
data SqlUpdate
Data type representing the SQL UPDATE statement. Can be created with the toUpdate function, and pretty printed with the ppUpdate function.
Constructors
SqlUpdate TableName [String] [String]Update the rows in table TableName that corresponds to the criterias supplid with the second field with values from the last field.
data SqlDelete
Data type representing the SQL DELETE statement. Can be created with the toDelete function, and pretty printed with the ppDelete function.
Constructors
SqlDelete TableName [String]Delete the rows in the table TableName that corresponds to the criterias supplied as a list of strings in the last field.
data SqlInsert
Data type representing the SQL INSERT statement.
Constructors
SqlInsert TableName [(Attribute, String)]
SqlInsertQuery TableName SqlSelect
Function Declarations
toSql :: PrimQuery -> SqlSelect
Creates a SqlSelect based on the PrimQuery supplied. Corresponds to the SQL statement SELECT.
ppSql :: SqlSelect -> Doc
Pretty prints a SqlSelect
toUpdate
:: TableNameName of the table to update.
-> [PrimExpr]Which data to update.
-> AssocUpdate the data with this.
-> SqlUpdate
Creates a SqlUpdate. Corresponds to the SQL statement UPDATE which updates data in a table.
ppUpdate :: SqlUpdate -> Doc
Pretty prints a SqlUpdate
toDelete
:: TableNameName of the table
-> [PrimExpr]Rows to be deleted.
-> SqlDelete
Creates a SqlDelete. Corresponds to the SQL statement DELETE which deletes rows in a table.
ppDelete :: SqlDelete -> Doc
toInsert
:: TableNameName of the table
-> AssocWhat to insert.
-> SqlInsert
Creates a SqlInsert. Almost the same as to InsertQuery except that it take a Assoc instead of a PrimQuery as second argument.
ppInsert :: SqlInsert -> Doc
toInsertQuery
:: TableNameName of the table
-> PrimQueryWhat to insert
-> SqlInsert
Creates a SqlInsert. Corresponds to the SQL statement INSERT INTO which is used to insert new rows in a table.
toCreateDB
:: Stringname of the database.
-> SqlCreate
Use this to create a SqlCreate data type corresponding to the SQL statement CREATE DATABASE which creates a new database.
toCreateTable
:: TableNamename of the table to be created.
-> [(Attribute, FieldDesc)]List of Attributes and FiledDescs that describes the table.
-> SqlCreate
Use this to create a SqlCreate data type corresponding to the SQL statement CREATE which creates a new table.
ppCreate :: SqlCreate -> Doc
Pretty prints a SqlCreate.
toDropDB :: String -> SqlDrop
Creates a SqlDrop that delete the database with the name given as the first argument.
toDropTable :: TableName -> SqlDrop
Creates a SqlDrop that delete the database named in the first argument.
ppDrop :: SqlDrop -> Doc
Pretty prints a SqlDrop.
Produced by Haddock version 0.8