-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Backend for the persistent library using MySQL database server.
--   
--   This package contains a backend for persistent using the MySQL
--   database server. Internally it uses the <tt>mysql-simple</tt> and
--   <tt>mysql</tt> packages in order to access the database.
--   
--   This package supports only MySQL 5.1 and above. However, it has been
--   tested only on MySQL 5.5. Only the InnoDB storage engine is officially
--   supported.
--   
--   Known problems:
--   
--   <ul>
--   <li>This package does not support statements inside other
--   statements.</li>
--   </ul>
@package persistent-mysql
@version 2.6.1


-- | A MySQL backend for <tt>persistent</tt>.
module Database.Persist.MySQL

-- | Create a MySQL connection pool and run the given action. The pool is
--   properly released after the action finishes using it. Note that you
--   should not use the given <a>ConnectionPool</a> outside the action
--   since it may be already been released.
withMySQLPool :: (MonadIO m, MonadLogger m, MonadBaseControl IO m, IsSqlBackend backend) => ConnectInfo -> Int -> (Pool backend -> m a) -> m a

-- | Same as <a>withMySQLPool</a>, but instead of opening a pool of
--   connections, only one connection is opened.
withMySQLConn :: (MonadBaseControl IO m, MonadIO m, MonadLogger m, IsSqlBackend backend) => ConnectInfo -> (backend -> m a) -> m a

-- | Create a MySQL connection pool. Note that it's your responsibility to
--   properly close the connection pool when unneeded. Use
--   <a>withMySQLPool</a> for automatic resource control.
createMySQLPool :: (MonadBaseControl IO m, MonadIO m, MonadLogger m, IsSqlBackend backend) => ConnectInfo -> Int -> m (Pool backend)
data ConnectInfo :: *
ConnectInfo :: String -> Word16 -> String -> String -> String -> [Option] -> FilePath -> Maybe SSLInfo -> ConnectInfo
[connectHost] :: ConnectInfo -> String
[connectPort] :: ConnectInfo -> Word16
[connectUser] :: ConnectInfo -> String
[connectPassword] :: ConnectInfo -> String
[connectDatabase] :: ConnectInfo -> String
[connectOptions] :: ConnectInfo -> [Option]
[connectPath] :: ConnectInfo -> FilePath
[connectSSL] :: ConnectInfo -> Maybe SSLInfo
data SSLInfo :: *
SSLInfo :: FilePath -> FilePath -> FilePath -> FilePath -> String -> SSLInfo
[sslKey] :: SSLInfo -> FilePath
[sslCert] :: SSLInfo -> FilePath
[sslCA] :: SSLInfo -> FilePath
[sslCAPath] :: SSLInfo -> FilePath

-- | Comma-separated list of cipher names.
[sslCiphers] :: SSLInfo -> String

-- | Default information for setting up a connection.
--   
--   Defaults are as follows:
--   
--   <ul>
--   <li>Server on <tt>localhost</tt></li>
--   <li>User <tt>root</tt></li>
--   <li>No password</li>
--   <li>Database <tt>test</tt></li>
--   <li>Character set <tt>utf8</tt></li>
--   </ul>
--   
--   Use as in the following example:
--   
--   <pre>
--   connect defaultConnectInfo { connectHost = "db.example.com" }
--   </pre>
defaultConnectInfo :: ConnectInfo

-- | Default (empty) information for setting up an SSL connection.
defaultSSLInfo :: SSLInfo

-- | Information required to connect to a MySQL database using
--   <tt>persistent</tt>'s generic facilities. These values are the same
--   that are given to <a>withMySQLPool</a>.
data MySQLConf
MySQLConf :: ConnectInfo -> Int -> MySQLConf

-- | The connection information.
[myConnInfo] :: MySQLConf -> ConnectInfo

-- | How many connections should be held on the connection pool.
[myPoolSize] :: MySQLConf -> Int

-- | Mock a migration even when the database is not present. This function
--   will mock the migration for a database even when the actual database
--   isn't already present in the system.
mockMigration :: Migration -> IO ()

-- | MySQL specific <a>upsert</a>. This will prevent multiple queries, when
--   one will do.
insertOnDuplicateKeyUpdate :: (PersistEntityBackend record ~ BaseBackend backend, PersistEntity record, MonadIO m, PersistStore backend, backend ~ SqlBackend) => record -> [Update record] -> SqlPersistT m ()

-- | Do a bulk insert on the given records in the first parameter. In the
--   event that a key conflicts with a record currently in the database,
--   the second and third parameters determine what will happen.
--   
--   The second parameter is a list of fields to copy from the original
--   value. This allows you to specify that, when a collision occurs,
--   you'll just update the value in the database with the field values
--   that you inserted.
--   
--   The third parameter is a list of updates to perform that are
--   independent of the value that is provided. You can use this to
--   increment a counter value. These updates only occur if the original
--   record is present in the database.
insertManyOnDuplicateKeyUpdate :: (PersistEntityBackend record ~ SqlBackend, PersistEntity record, MonadIO m) => [record] -> [SomeField record] -> [Update record] -> SqlPersistT m ()

-- | This wraps values of an Entity's <a>EntityField</a>, making them have
--   the same type. This allows them to be put in lists.
data SomeField record
[SomeField] :: EntityField record typ -> SomeField record
instance GHC.Show.Show Database.Persist.MySQL.MySQLConf
instance Database.MySQL.Simple.Param.Param Database.Persist.MySQL.P
instance Data.Aeson.Types.FromJSON.FromJSON Database.Persist.MySQL.MySQLConf
instance Database.Persist.Class.PersistConfig.PersistConfig Database.Persist.MySQL.MySQLConf
