Portability | portable |
---|---|
Stability | experimental |
Maintainer | Bryan O'Sullivan <bos@mailrank.com> |
A low-level client library for the MySQL database, implemented as
bindings to the C mysqlclient
API.
- data ConnectInfo = ConnectInfo {}
- data SSLInfo = SSLInfo {}
- type Seconds = Word
- data Protocol
- data Option
- = ConnectTimeout Seconds
- | Compress
- | NamedPipe
- | InitCommand ByteString
- | ReadDefaultFile FilePath
- | ReadDefaultGroup ByteString
- | CharsetDir FilePath
- | CharsetName String
- | LocalInFile Bool
- | Protocol Protocol
- | SharedMemoryBaseName ByteString
- | ReadTimeout Seconds
- | WriteTimeout Seconds
- | UseRemoteConnection
- | UseEmbeddedConnection
- | GuessConnection
- | ClientIP ByteString
- | SecureAuth Bool
- | ReportDataTruncation Bool
- | Reconnect Bool
- | SSLVerifyServerCert Bool
- | FoundRows
- | IgnoreSIGPIPE
- | IgnoreSpace
- | Interactive
- | LocalFiles
- | MultiResults
- | MultiStatements
- | NoSchema
- defaultConnectInfo :: ConnectInfo
- defaultSSLInfo :: SSLInfo
- data Connection
- data Result
- data Field
- data Type
- data Row
- data MySQLError
- connect :: ConnectInfo -> IO Connection
- close :: Connection -> IO ()
- autocommit :: Connection -> Bool -> IO ()
- ping :: Connection -> IO ()
- changeUser :: Connection -> String -> String -> Maybe String -> IO ()
- selectDB :: Connection -> String -> IO ()
- setCharacterSet :: Connection -> String -> IO ()
- threadId :: Connection -> IO Word
- serverInfo :: Connection -> IO String
- hostInfo :: Connection -> IO String
- protocolInfo :: Connection -> IO Word
- characterSet :: Connection -> IO String
- sslCipher :: Connection -> IO (Maybe String)
- serverStatus :: Connection -> IO String
- query :: Connection -> ByteString -> IO ()
- escape :: Connection -> ByteString -> IO ByteString
- fieldCount :: Either Connection Result -> IO Int
- affectedRows :: Connection -> IO Int64
- isResultValid :: Result -> IO Bool
- freeResult :: Result -> IO ()
- storeResult :: Connection -> IO Result
- useResult :: Connection -> IO Result
- fetchRow :: Result -> IO [Maybe ByteString]
- fetchFields :: Result -> IO [Field]
- dataSeek :: Result -> Int64 -> IO ()
- rowSeek :: Result -> Row -> IO Row
- rowTell :: Result -> IO Row
- nextResult :: Connection -> IO Bool
- commit :: Connection -> IO ()
- rollback :: Connection -> IO ()
- clientInfo :: String
- clientVersion :: Word
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
ConnectInfo | |
|
defaultConnectInfo :: ConnectInfoSource
Default information for setting up a connection.
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
A description of a field (column) of a table.
Column types supported by MySQL.
Connection management
connect :: ConnectInfo -> IO ConnectionSource
autocommit :: Connection -> Bool -> IO ()Source
ping :: Connection -> IO ()Source
changeUser :: Connection -> String -> String -> Maybe String -> IO ()Source
setCharacterSet :: Connection -> String -> IO ()Source
Connection information
threadId :: Connection -> IO WordSource
serverInfo :: Connection -> IO StringSource
hostInfo :: Connection -> IO StringSource
protocolInfo :: Connection -> IO WordSource
characterSet :: Connection -> IO StringSource
serverStatus :: Connection -> IO StringSource
Querying
query :: Connection -> ByteString -> IO ()Source
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.
affectedRows :: Connection -> IO Int64Source
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.
fetchFields :: Result -> IO [Field]Source
Multiple results
nextResult :: Connection -> IO BoolSource
Transactions
commit :: Connection -> IO ()Source
rollback :: Connection -> IO ()Source