Adapter module for MySQL.
It handles and pools the connections to the MySQL database using
mariaex and a connection pool, such as
MySQL options split in different categories described below. All options should be given via the repository configuration. These options are also passed to the module specified in the
:pool option, so check that module’s documentation for more options.
Those options should be set in the config file and require recompilation in order to make an effect.
:adapter- The adapter name, in this case,
:pool- The connection pool module, defaults to
:pool_timeout- The default timeout to use on pool calls, defaults to
:timeout- The default timeout to use on queries, defaults to
:hostname- Server hostname
:port- Server port (default: 3306)
:password- User password
:ssl- Set to true if ssl should be used (default: false)
:ssl_opts- A list of ssl options, see Erlang’s
:parameters- Keyword list of connection parameters
:connect_timeout- The timeout for establishing new connections (default: 5000)
:socket_options- Specifies socket configuration
:socket_options are particularly useful when configuring the size of both send and receive buffers. For example, when Ecto starts with a pool of 20 connections, the memory usage may quickly grow from 20MB to 50MB based on the operating system default values for TCP buffers. It is advised to stick with the operating system defaults but they can be tweaked if desired:
socket_options: [recbuf: 8192, sndbuf: 8192]
We also recommend developers to consult the Mariaex documentation for a complete listing of all supported options.
:charset- the database encoding (default: “utf8”)
:collation- the collation order
:dump_path- where to place dumped structures
There are some limitations when using Ecto with MySQL that one needs to be aware of.
Since Ecto uses transactions, MySQL users running old versions (5.1 and before) must ensure their tables use the InnoDB engine as the default (MyISAM) does not support transactions.
Tables created by Ecto are guaranteed to use InnoDB, regardless of the MySQL version.
MySQL does not support UUID types. Ecto emulates them by using
Because MySQL does not support RETURNING clauses in INSERT and UPDATE, it does not support the
:read_after_writes option of
MySQL does not support migrations inside transactions as it automatically commits after some commands like CREATE TABLE. Therefore MySQL migrations does not run inside transactions.
Old MySQL versions did not support usec in datetime while more recent versions would round or truncate the usec value.
Therefore, in case the user decides to use microseconds in datetimes and timestamps with MySQL, be aware of such differences and consult the documentation for your MySQL version.
Assuming your version of MySQL supports microsecond precision, you will need to explicitly set it on the relevant columns in your migration. For explicitly declared columns you can add the
size: 6 option. If you’re using the
timestamps() helper you can use
© 2012 Plataformatec
Licensed under the Apache License, Version 2.0.