mysql-simple-0.4.5: A mid-level MySQL client library.

Copyright(c) 2011 MailRank Inc.
LicenseBSD3
MaintainerPaul Rouse <pyr@doynton.org>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Database.MySQL.Simple.Result

Description

The Result typeclass, for converting a single value in a row returned by a SQL query into a more useful Haskell representation.

A Haskell numeric type is considered to be compatible with all MySQL numeric types that are less accurate than it. For instance, the Haskell Double type is compatible with the MySQL Long type because it can represent a Long exactly. On the other hand, since a Double might lose precision if representing a LongLong, the two are not considered compatible.

Synopsis

Documentation

class Result a where Source #

A type that may be converted from a SQL type.

Minimal complete definition

convert

Methods

convert :: Field -> Maybe ByteString -> a Source #

Convert a SQL value to a Haskell value.

Throws a ResultError if conversion fails.

Instances

Result Bool Source # 
Result Double Source # 
Result Float Source # 
Result Int Source # 
Result Int8 Source # 
Result Int16 Source # 
Result Int32 Source # 
Result Int64 Source # 
Result Integer Source # 
Result Word Source # 
Result Word8 Source # 
Result Word16 Source # 
Result Word32 Source # 
Result Word64 Source # 
Result ByteString Source # 
Result ByteString Source # 
Result Text Source # 
Result Text Source # 
Result TimeOfDay Source # 
Result UTCTime Source # 
Result Day Source # 
Result [Char] Source # 
Result a => Result (Maybe a) Source # 
Result (Ratio Integer) Source # 

data ResultError Source #

Exception thrown if conversion from a SQL value to a Haskell value fails.

Constructors

Incompatible

The SQL and Haskell types are not compatible.

UnexpectedNull

A SQL NULL was encountered when the Haskell type did not permit it.

ConversionFailed

The SQL value could not be parsed, or could not be represented as a valid Haskell value, or an unexpected low-level error occurred (e.g. mismatch between metadata and actual data in a row).