mysql-0.1.1.7: A low-level MySQL client library.

Portabilityportable
Stabilityexperimental
MaintainerBryan O'Sullivan <bos@serpentine.com>
Safe HaskellNone

Database.MySQL.Base

Contents

Description

A low-level client library for the MySQL database, implemented as bindings to the C mysqlclient API.

Synopsis

Licensing

Important licensing note: This library is BSD-licensed under the terms of the MySQL FOSS License Exception http://www.mysql.com/about/legal/licensing/foss-exception/.

Since this library links against the GPL-licensed mysqlclient library, a non-open-source application that uses it may be subject to the terms of the GPL.

data ConnectInfo Source

Constructors

ConnectInfo 

Fields

connectHost :: String
 
connectPort :: Word16
 
connectUser :: String
 
connectPassword :: String
 
connectDatabase :: String
 
connectOptions :: [Option]
 
connectPath :: FilePath
 
connectSSL :: Maybe SSLInfo
 

Instances

Eq ConnectInfo 
Read ConnectInfo 
Show ConnectInfo 
Typeable ConnectInfo 

data SSLInfo Source

Constructors

SSLInfo 

Fields

sslKey :: FilePath
 
sslCert :: FilePath
 
sslCA :: FilePath
 
sslCAPath :: FilePath
 
sslCiphers :: String

Comma-separated list of cipher names.

Instances

Eq SSLInfo 
Read SSLInfo 
Show SSLInfo 
Typeable SSLInfo 

type Seconds = WordSource

data Protocol Source

Constructors

TCP 
Socket 
Pipe 
Memory 

Instances

Enum Protocol 
Eq Protocol 
Read Protocol 
Show Protocol 
Typeable Protocol 

defaultConnectInfo :: ConnectInfoSource

Default information for setting up a connection.

Defaults are as follows:

  • Server on localhost
  • User root
  • No password
  • Database test
  • Character set utf8

Use as in the following example:

 connect defaultConnectInfo { connectHost = "db.example.com" }

defaultSSLInfo :: SSLInfoSource

Default (empty) information for setting up an SSL connection.

data Connection Source

Connection to a MySQL database.

Instances

Typeable Connection 

data Result Source

Result of a database query.

Instances

Typeable Result 

data Type Source

Column types supported by MySQL.

Instances

Enum Type 
Eq Type 
Show Type 
Typeable Type 

data Row Source

A row cursor, used by rowSeek and rowTell.

Instances

Typeable Row 

data MySQLError Source

Instances

Eq MySQLError 
Show MySQLError 
Typeable MySQLError 
Exception MySQLError 

Connection management

connect :: ConnectInfo -> IO ConnectionSource

Connect to a database.

close :: Connection -> IO ()Source

Close a connection, and mark any outstanding Result as invalid.

autocommit :: Connection -> Bool -> IO ()Source

Turn autocommit on or off.

By default, MySQL runs with autocommit mode enabled. In this mode, as soon as you modify a table, MySQL stores your modification permanently.

changeUser :: Connection -> String -> String -> Maybe String -> IO ()Source

selectDB :: Connection -> String -> IO ()Source

setCharacterSet :: Connection -> String -> IO ()Source

Connection information

hostInfo :: Connection -> IO StringSource

sslCipher :: Connection -> IO (Maybe String)Source

Querying

query :: Connection -> ByteString -> IO ()Source

insertID :: Connection -> IO Word64Source

Return the value generated for an AUTO_INCREMENT column by the previous INSERT or UPDATE statement.

See http://dev.mysql.com/doc/refman/5.5/en/mysql-insert-id.html

Escaping

escape :: Connection -> ByteString -> IO ByteStringSource

Results

fieldCount :: Either Connection Result -> IO IntSource

Return the number of fields (columns) in a result.

  • If Left Connection, returns the number of columns for the most recent query on the connection.
  • For Right Result, returns the number of columns in each row of this result.

The number of columns may legitimately be zero.

Working with results

isResultValid :: Result -> IO BoolSource

Check whether a Result is still valid, i.e. backed by a live MYSQL_RES value.

freeResult :: Result -> IO ()Source

Immediately free the MYSQL_RES value associated with this Result, and mark the Result as invalid.

storeResult :: Connection -> IO ResultSource

Retrieve a complete result.

Any previous outstanding Result is first marked as invalid.

useResult :: Connection -> IO ResultSource

Initiate a row-by-row retrieval of a result.

Any previous outstanding Result is first marked as invalid.

fetchRow :: Result -> IO [Maybe ByteString]Source

dataSeek :: Result -> Int64 -> IO ()Source

Multiple results

nextResult :: Connection -> IO BoolSource

Read the next statement result. Returns True if another result is available, False otherwise.

This function marks the current Result as invalid, if one exists.

Transactions

commit :: Connection -> IO ()Source

Commit the current transaction.

rollback :: Connection -> IO ()Source

Roll back the current transaction.

General information