haskelldb-0.12: SQL unwrapper for Haskell.Source codeContentsIndex
Database.HaskellDB.DBSpec
Portabilitynon-portable
Stabilityexperimental
Maintainerhaskelldb-users@lists.sourceforge.net
Description
DBSpec is the new and improved way of specifying databases. It is designed to be able to describe a database in such a way that it can easily be converted to a DBDirect-spec OR directly into a database
Synopsis
data DBInfo = DBInfo {
dbname :: String
opts :: DBOptions
tbls :: [TInfo]
}
data TInfo = TInfo {
tname :: String
cols :: [CInfo]
}
data CInfo = CInfo {
cname :: String
descr :: FieldDesc
}
data DBOptions = DBOptions {
useBString :: Bool
makeIdent :: MakeIdentifiers
}
type FieldDesc = (FieldType, Bool)
data FieldType
= StringT
| IntT
| IntegerT
| DoubleT
| BoolT
| CalendarTimeT
| BStrT Int
makeDBSpec :: String -> DBOptions -> [TInfo] -> DBInfo
makeTInfo :: String -> [CInfo] -> TInfo
makeCInfo :: String -> FieldDesc -> CInfo
constructNonClashingDBInfo :: DBInfo -> DBInfo
ppDBInfo :: DBInfo -> Doc
ppTInfo :: TInfo -> Doc
ppCInfo :: CInfo -> Doc
ppDBOptions :: DBOptions -> Doc
dbInfoToDoc :: DBInfo -> Doc
finalizeSpec :: DBInfo -> DBInfo
dbToDBSpec :: Bool -> MakeIdentifiers -> String -> Database -> IO DBInfo
dbSpecToDatabase :: Database -> DBInfo -> IO ()
Documentation
data DBInfo Source
Defines a database layout, top level
Constructors
DBInfo
dbname :: StringThe name of the database
opts :: DBOptionsAny options (i.e whether to use Bounded Strings)
tbls :: [TInfo]Tables this database contains
show/hide Instances
data TInfo Source
Constructors
TInfo
tname :: StringThe name of the table
cols :: [CInfo]The columns in this table
show/hide Instances
data CInfo Source
Constructors
CInfo
cname :: StringThe name of this column
descr :: FieldDescThe description of this column
show/hide Instances
data DBOptions Source
Constructors
DBOptions
useBString :: BoolUse Bounded Strings?
makeIdent :: MakeIdentifiersConversion routines from Database identifiers to Haskell identifiers
show/hide Instances
type FieldDesc = (FieldType, Bool)Source
The type and nullable flag of a database column
data FieldType Source
A database column type
Constructors
StringT
IntT
IntegerT
DoubleT
BoolT
CalendarTimeT
BStrT Int
show/hide Instances
makeDBSpecSource
:: StringThe name of the Database
-> DBOptionsOptions
-> [TInfo]Tables
-> DBInfoThe generated DBInfo
Creates a DBInfo
makeTInfoSource
:: StringThe table name
-> [CInfo]Columns
-> TInfoThe generated TInfo
Creates a TInfo
makeCInfoSource
:: StringThe column name
-> FieldDescWhat the column contains
-> CInfoThe generated CInfo
Creates a CInfo
constructNonClashingDBInfo :: DBInfo -> DBInfoSource
Constructs a DBInfo that doesn't cause nameclashes
ppDBInfo :: DBInfo -> DocSource
Pretty prints a DBInfo
ppTInfo :: TInfo -> DocSource
ppCInfo :: CInfo -> DocSource
ppDBOptions :: DBOptions -> DocSource
dbInfoToDoc :: DBInfo -> DocSource
Creates a valid declaration of a DBInfo. The variable name will be the same as the database name
finalizeSpec :: DBInfo -> DBInfoSource
Does a final touching up of a DBInfo before it is used by i.e DBDirect. This converts any Bounded Strings to ordinary strings if that flag is set.
dbToDBSpecSource
:: BoolUse bounded strings?
-> MakeIdentifiersstyle of generated Haskell identifiers, cOLUMN_NAME vs. columnName
-> Stringthe name our database should have
-> Databasethe database connection
-> IO DBInforeturn a DBInfo
Connects to a database and generates a specification from it
dbSpecToDatabaseSource
:: DatabaseA Database
-> DBInfoThe DBInfo to generate from
-> IO ()
Converts a DBInfo to a real life Database, note that the database must exist for this to work
Produced by Haddock version 2.6.0