haskelldb-0.10: SQL unwrapper for Haskell.ContentsIndex
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
}
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 -> String -> Database -> IO DBInfo
dbSpecToDatabase :: Database -> DBInfo -> IO ()
Documentation
data DBInfo
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
Constructors
TInfo
tname :: StringThe name of the table
cols :: [CInfo]The columns in this table
show/hide Instances
data CInfo
Constructors
CInfo
cname :: StringThe name of this column
descr :: FieldDescThe description of this column
show/hide Instances
data DBOptions
Constructors
DBOptions
useBString :: BoolUse Bounded Strings?
show/hide Instances
type FieldDesc = (FieldType, Bool)
The type and nullable flag of a database column
data FieldType
A database column type
Constructors
StringT
IntT
IntegerT
DoubleT
BoolT
CalendarTimeT
BStrT Int
show/hide Instances
makeDBSpec
:: StringThe name of the Database
-> DBOptionsOptions
-> [TInfo]Tables
-> DBInfoThe generated DBInfo
Creates a DBInfo
makeTInfo
:: StringThe table name
-> [CInfo]Columns
-> TInfoThe generated TInfo
Creates a TInfo
makeCInfo
:: StringThe column name
-> FieldDescWhat the column contains
-> CInfoThe generated CInfo
Creates a CInfo
constructNonClashingDBInfo :: DBInfo -> DBInfo
Constructs a DBInfo that doesn't cause nameclashes
ppDBInfo :: DBInfo -> Doc
Pretty prints a DBInfo
ppTInfo :: TInfo -> Doc
ppCInfo :: CInfo -> Doc
ppDBOptions :: DBOptions -> Doc
dbInfoToDoc :: DBInfo -> Doc
Creates a valid declaration of a DBInfo. The variable name will be the same as the database name
finalizeSpec :: DBInfo -> DBInfo
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.
dbToDBSpec
:: BoolUse bounded strings?
-> Stringthe name our database should have
-> Databasethe database connection
-> IO DBInforeturn a DBInfo
Connects to a database and generates a specification from it
dbSpecToDatabase
:: 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 0.8