Ecto v1.1.0 Ecto.Adapters.MySQL

Adapter module for MySQL.

It handles and pools the connections to the MySQL database using mariaex and a connection pool, such as poolboy.

Options

MySQL options split in different categories described below. All options should be given via the repository configuration.

Compile time 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, Ecto.Adapters.MySQL
  • :pool - The connection pool module, defaults to Ecto.Pools.Poolboy
  • :pool_timeout - The default timeout to use on pool calls, defaults to 5000
  • :timeout - The default timeout to use on queries, defaults to 15000
  • :log_level - The level to use when logging queries (default: :debug)

Connection options

  • :hostname - Server hostname
  • :port - Server port (default: 3306)
  • :username - Username
  • :password - User password
  • :parameters - Keyword list of connection parameters
  • :ssl - Set to true if ssl should be used (default: false)
  • :ssl_opts - A list of ssl options, see ssl docs
  • :connect_timeout - The timeout in miliseconds for establishing new connections (default: 5000)

Storage options

  • :charset - the database encoding (default: “utf8”)
  • :collation - the collation order

Limitations

There are some limitations when using Ecto with MySQL that one needs to be aware of.

Engine

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.

UUIDs

MySQL does not support UUID types. Ecto emulates them by using binary(16).

Read after writes

Because MySQL does not support RETURNING clauses in INSERT and UPDATE, it does not support the :read_after_writes option of Ecto.Schema.field/3.

DDL Transaction

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.

usec in datetime

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.

Summary

Functions

Callback implementation for Ecto.Adapter.dump/2

Callback implementation for Ecto.Adapter.embed_id/1

Callback implementation for Ecto.Adapter.load/2

Functions

dump(type, value)

Callback implementation for Ecto.Adapter.dump/2.

embed_id()

Callback implementation for Ecto.Adapter.embed_id/1.

load(type, value)

Callback implementation for Ecto.Adapter.load/2.