{"id":20302208,"url":"https://github.com/elixir-ecto/myxql","last_synced_at":"2025-05-14T12:11:20.948Z","repository":{"id":33817425,"uuid":"146284207","full_name":"elixir-ecto/myxql","owner":"elixir-ecto","description":"MySQL 5.5+ driver for Elixir","archived":false,"fork":false,"pushed_at":"2025-04-23T09:30:00.000Z","size":710,"stargazers_count":281,"open_issues_count":4,"forks_count":67,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-05-07T11:02:52.748Z","etag":null,"topics":["database","elixir","mysql"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elixir-ecto.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-08-27T10:45:58.000Z","updated_at":"2025-04-25T22:56:42.000Z","dependencies_parsed_at":"2023-01-15T02:44:16.531Z","dependency_job_id":"3c1858f0-cc55-46f1-9b81-31ec89bad5e9","html_url":"https://github.com/elixir-ecto/myxql","commit_stats":{"total_commits":600,"total_committers":23,"mean_commits":26.08695652173913,"dds":0.09833333333333338,"last_synced_commit":"02c38b61ecc12c3f9aa5cbf0ff866b16d92a80fb"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-ecto%2Fmyxql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-ecto%2Fmyxql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-ecto%2Fmyxql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-ecto%2Fmyxql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elixir-ecto","download_url":"https://codeload.github.com/elixir-ecto/myxql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254140763,"owners_count":22021219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","elixir","mysql"],"created_at":"2024-11-14T16:29:42.112Z","updated_at":"2025-05-14T12:11:20.877Z","avatar_url":"https://github.com/elixir-ecto.png","language":"Elixir","funding_links":[],"categories":["Elixir"],"sub_categories":[],"readme":"# MyXQL\n\n[![CI](https://github.com/elixir-ecto/myxql/workflows/CI/badge.svg)](https://github.com/elixir-ecto/myxql/actions?query=workflow%3ACI)\n\nMySQL driver for Elixir.\n\nDocumentation: \u003chttp://hexdocs.pm/myxql\u003e\n\n## Features\n\n  * Automatic decoding and encoding of Elixir values to and from MySQL text and binary protocols\n  * Supports transactions, prepared queries, streaming, pooling and more via [DBConnection](https://github.com/elixir-ecto/db_connection)\n  * Supports MySQL 5.5+, 8.0, and MariaDB 10.3\n  * Supports `mysql_native_password`, `sha256_password`, and `caching_sha2_password`\n    authentication plugins\n\n## Usage\n\nAdd `:myxql` to your dependencies:\n\n```elixir\ndef deps do\n  [\n    {:myxql, \"~\u003e 0.7.0\"}\n  ]\nend\n```\n\nMake sure you are using the latest version!\n\n```elixir\niex\u003e {:ok, pid} = MyXQL.start_link(username: \"root\")\niex\u003e MyXQL.query!(pid, \"CREATE DATABASE IF NOT EXISTS blog\")\n\niex\u003e {:ok, pid} = MyXQL.start_link(username: \"root\", database: \"blog\")\niex\u003e MyXQL.query!(pid, \"CREATE TABLE posts IF NOT EXISTS (id serial primary key, title text)\")\n\niex\u003e MyXQL.query!(pid, \"INSERT INTO posts (`title`) VALUES ('Post 1')\")\n%MyXQL.Result{columns: nil, connection_id: 11204,, last_insert_id: 1, num_rows: 1, num_warnings: 0, rows: nil}\n\niex\u003e MyXQL.query(pid, \"INSERT INTO posts (`title`) VALUES (?), (?)\", [\"Post 2\", \"Post 3\"])\n%MyXQL.Result{columns: nil, connection_id: 11204, last_insert_id: 2, num_rows: 2, num_warnings: 0, rows: nil}\n\niex\u003e MyXQL.query(pid, \"SELECT * FROM posts\")\n{:ok,\n %MyXQL.Result{\n   columns: [\"id\", \"title\"],\n   connection_id: 11204,\n   last_insert_id: nil,\n   num_rows: 3,\n   num_warnings: 0,\n   rows: [[1, \"Post 1\"], [2, \"Post 2\"], [3, \"Post 3\"]]\n }}\n```\n\nIt's recommended to start MyXQL under supervision tree:\n\n```elixir\ndefmodule MyApp.Application do\n  use Application\n\n  def start(_type, _args) do\n    children = [\n      {MyXQL, username: \"root\", name: :myxql}\n    ]\n\n    Supervisor.start_link(children, opts)\n  end\nend\n```\n\nand then we can refer to it by its `:name`:\n\n```elixir\niex\u003e MyXQL.query!(:myxql, \"SELECT NOW()\").rows\n[[~N[2018-12-28 13:42:31]]]\n```\n\n## Mariaex Compatibility\n\nSee [Mariaex Compatibility](https://github.com/elixir-ecto/myxql/blob/master/MARIAEX_COMPATIBILITY.md) page for transition between drivers.\n\n## Data representation\n\n| MySQL                   | Elixir                                          |\n|-------------------------|-------------------------------------------------|\n| `NULL`                  | `nil`                                           |\n| `bool`                  | `0`, `1`                                        |\n| `int`                   | `42`                                            |\n| `float`                 | `42.0`                                          |\n| `decimal`               | `#Decimal\u003c42.0\u003e` (1)                            |\n| `date`                  | `~D[2013-10-12]` (2)                            |\n| `time`                  | `~T[00:37:14]` (3)                              |\n| `datetime`              | `~N[2013-10-12 00:37:14]` (2), (4)              |\n| `timestamp`             | `~U[2013-10-12 00:37:14Z]` (2), (4), (7)        |\n| `json`                  | `%{\"foo\" =\u003e \"bar\"}` (5)                         |\n| `char`                  | `\"é\"`                                           |\n| `text`                  | `\"myxql\"`                                       |\n| `binary`                | `\u003c\u003c1, 2, 3\u003e\u003e`                                   |\n| `bit`                   | `\u003c\u003c1::size(1), 0::size(1)\u003e\u003e`                    |\n| `point`, `polygon`, ... | `%Geo.Point{coordinates: {0.0, 1.0}}, ...` (6)  |\n\nNotes:\n\n1. See [Decimal](https://github.com/ericmj/decimal)\n\n2. When using SQL mode that allows them, MySQL \"zero\" dates and datetimes are represented as `:zero_date` and `:zero_datetime` respectively.\n\n3. Values that are negative or greater than `24:00:00` cannot be decoded\n\n4. Datetime fields are represented as `NaiveDateTime`, however a UTC `DateTime` can be used for encoding as well\n\n5. MySQL added a native JSON type in version 5.7.8, if you're using earlier versions,\nremember to use TEXT column for your JSON field.\n\n6. See \"Geometry support\" section below\n\n7. See \"UTC required\" section below\n\n## JSON support\n\nMyXQL comes with JSON support via the [Jason](https://github.com/michalmuskala/jason) library.\n\nTo use it, add `:jason` to your dependencies:\n\n```elixir\n{:jason, \"~\u003e 1.0\"}\n```\n\nYou can customize it to use another library via the `:json_library` configuration:\n\n```elixir\nconfig :myxql, :json_library, SomeJSONModule\n```\n\n## Geometry support\n\nMyXQL comes with Geometry types support via the [Geo](https://github.com/bryanjos/geo) package.\n\nTo use it, add `:geo` to your dependencies:\n\n```elixir\n{:geo, \"~\u003e 3.3\"}\n```\n\nNote, some structs like `%Geo.PointZ{}` does not have equivalent on the MySQL server side and thus\nshouldn't be used.\n\nIf you're using MyXQL geometry types with Ecto and need to for example accept a WKT format as user\ninput, consider implementing an [custom Ecto type](https://hexdocs.pm/ecto/Ecto.Type.html).\n\n## UTC required\n\nWhen using `DateTime` type, MyXQL assumes the server is configured with the UTC time\nzone. If that is not the case, set it manually with `MyXQL.start_link/1` and\n`:after_connect` option:\n\n```elixir\nMyXQL.start_link(after_connect: \u0026MyXQL.query!(\u00261, \"SET time_zone = '+00:00'\"))\n```\n\nor when configuring `Ecto.Repo`:\n\n```elixir\nconfig :myapp, MyApp.Repo,\n  after_connect: {MyXQL, :query!, [\"SET time_zone = '+00:00'\", []]}\n```\n\n## Contributing\n\nRun tests:\n\n```text\ngit clone git@github.com:elixir-ecto/myxql.git\ncd myxql\nmix deps.get\nmix test\n```\n\nSee [`scripts/test-versions.sh`](scripts/test-versions.sh) for scripts used to test against different server versions.\n\n## License\n\nThe source code is under Apache License 2.0.\n\nCopyright (c) 2018 Plataformatec \\\nCopyright (c) 2020 Dashbit\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felixir-ecto%2Fmyxql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felixir-ecto%2Fmyxql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felixir-ecto%2Fmyxql/lists"}