{"id":13491228,"url":"https://github.com/elixir-ecto/ecto","last_synced_at":"2025-12-17T01:03:09.020Z","repository":{"id":37561856,"uuid":"10649374","full_name":"elixir-ecto/ecto","owner":"elixir-ecto","description":"A toolkit for data mapping and language integrated query.","archived":false,"fork":false,"pushed_at":"2025-04-18T16:10:28.000Z","size":16090,"stargazers_count":6302,"open_issues_count":13,"forks_count":1439,"subscribers_count":162,"default_branch":"master","last_synced_at":"2025-05-05T16:05:54.705Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/ecto","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":"2013-06-12T18:42:06.000Z","updated_at":"2025-05-05T11:42:48.000Z","dependencies_parsed_at":"2024-01-09T07:38:44.933Z","dependency_job_id":"81f1e41f-07c1-4b71-9640-f37e004b79e7","html_url":"https://github.com/elixir-ecto/ecto","commit_stats":{"total_commits":5292,"total_committers":796,"mean_commits":6.648241206030151,"dds":0.660808767951625,"last_synced_commit":"4990abda4c504133f89deed469582785166208f5"},"previous_names":[],"tags_count":180,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-ecto%2Fecto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-ecto%2Fecto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-ecto%2Fecto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-ecto%2Fecto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elixir-ecto","download_url":"https://codeload.github.com/elixir-ecto/ecto/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253818596,"owners_count":21969189,"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":[],"created_at":"2024-07-31T19:00:54.743Z","updated_at":"2025-12-17T01:03:08.962Z","avatar_url":"https://github.com/elixir-ecto.png","language":"Elixir","funding_links":[],"categories":["Elixir","Top 20 packages","ORM and Datamapping","Projects","Uncategorized"],"sub_categories":["Misc","Uncategorized"],"readme":"\u003cimg width=\"250\" src=\"https://github.com/elixir-ecto/ecto/raw/master/guides/images/logo.png#gh-light-mode-only\" alt=\"Ecto\"\u003e\n\u003cimg width=\"250\" src=\"https://github.com/elixir-ecto/ecto/raw/master/guides/images/logo-white.png#gh-dark-mode-only\" alt=\"Ecto\"\u003e\n\n---\n\n[![Build Status](https://github.com/elixir-ecto/ecto/workflows/CI/badge.svg)](https://github.com/elixir-ecto/ecto/actions) [![Hex.pm](https://img.shields.io/hexpm/v/ecto.svg)](https://hex.pm/packages/ecto) [![Documentation](https://img.shields.io/badge/documentation-gray)](https://hexdocs.pm/ecto/)\n\n## Installation\n\nAdd `:ecto` to the list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:ecto, \"~\u003e 3.10\"}\n  ]\nend\n```\n\n## About\n\nEcto is a toolkit for data mapping and language integrated query for Elixir. Here is an example:\n\n```elixir\n# In your config/config.exs file\nconfig :my_app, ecto_repos: [Sample.Repo]\n\nconfig :my_app, Sample.Repo,\n  database: \"ecto_simple\",\n  username: \"postgres\",\n  password: \"postgres\",\n  hostname: \"localhost\",\n  port: \"5432\"\n\n# In your application code\ndefmodule Sample.Repo do\n  use Ecto.Repo,\n    otp_app: :my_app,\n    adapter: Ecto.Adapters.Postgres\nend\n\ndefmodule Sample.Weather do\n  use Ecto.Schema\n\n  schema \"weather\" do\n    field :city     # Defaults to type :string\n    field :temp_lo, :integer\n    field :temp_hi, :integer\n    field :prcp,    :float, default: 0.0\n  end\nend\n\ndefmodule Sample.App do\n  import Ecto.Query\n  alias Sample.{Weather, Repo}\n\n  def keyword_query do\n    query =\n      from w in Weather,\n           where: w.prcp \u003e 0 or is_nil(w.prcp),\n           select: w\n\n    Repo.all(query)\n  end\n\n  def pipe_query do\n    Weather\n    |\u003e where(city: \"Kraków\")\n    |\u003e order_by(:temp_lo)\n    |\u003e limit(10)\n    |\u003e Repo.all\n  end\nend\n```\n\nEcto is commonly used to interact with databases, such as PostgreSQL and MySQL via [Ecto.Adapters.SQL](https://hexdocs.pm/ecto_sql) ([source code](https://github.com/elixir-ecto/ecto_sql)). Ecto is also commonly used to map data from any source into Elixir structs, whether they are backed by a database or not.\n\nSee the [getting started guide](https://hexdocs.pm/ecto/getting-started.html) and the [online documentation](https://hexdocs.pm/ecto) for more information. Other resources available are:\n\n  * [Programming Ecto](https://pragprog.com/titles/wmecto/programming-ecto/), by Darin Wilson and Eric Meadows-Jönsson, which guides you from fundamentals up to advanced concepts\n\n  * [The Little Ecto Cookbook](https://dashbit.co/ebooks/the-little-ecto-cookbook), a free ebook by Dashbit, which is a curation of the existing Ecto guides with some extra contents\n\n## Usage\n\nYou need to add both Ecto and the database adapter as a dependency to your `mix.exs` file. The supported databases and their adapters are:\n\n| Database   | Ecto Adapter             | Dependencies                                     |\n| :--------- | :----------------------- | :----------------------------------------------- |\n| PostgreSQL | Ecto.Adapters.Postgres   | [ecto_sql][ecto_sql] + [postgrex][postgrex]      |\n| MySQL      | Ecto.Adapters.MyXQL      | [ecto_sql][ecto_sql] + [myxql][myxql]            |\n| MSSQL      | Ecto.Adapters.Tds        | [ecto_sql][ecto_sql] + [tds][tds]                |\n| SQLite3    | Ecto.Adapters.SQLite3    | [ecto_sqlite3][ecto_sqlite3]                     |\n| ClickHouse | Ecto.Adapters.ClickHouse | [ecto_ch][ecto_ch]                               |\n| ETS        | Etso                     | [etso][etso]                                     |\n\n[ecto_sql]: https://github.com/elixir-ecto/ecto_sql\n[postgrex]: https://github.com/elixir-ecto/postgrex\n[myxql]: https://github.com/elixir-ecto/myxql\n[tds]: https://github.com/livehelpnow/tds\n[ecto_sqlite3]: https://github.com/elixir-sqlite/ecto_sqlite3\n[etso]: https://github.com/evadne/etso\n[ecto_ch]: https://github.com/plausible/ecto_ch\n\nFor example, if you want to use PostgreSQL, add to your `mix.exs` file:\n\n```elixir\ndefp deps do\n  [\n    {:ecto_sql, \"~\u003e 3.0\"},\n    {:postgrex, \"\u003e= 0.0.0\"}\n  ]\nend\n```\n\nThen run `mix deps.get` in your shell to fetch the dependencies. If you want to use another database, just choose the proper dependency from the table above.\n\nFinally, in the repository definition, you will need to specify the `adapter:` respective to the chosen dependency. For PostgreSQL it is:\n\n```elixir\ndefmodule MyApp.Repo do\n  use Ecto.Repo,\n    otp_app: :my_app,\n    adapter: Ecto.Adapters.Postgres,\n  ...\n```\n\n### IPv6 support\n\nIf your database's host resolves to ipv6 address you should\nadd `socket_options: [:inet6]` to configuration block like below:\n\n```elixir\nimport Mix.Config\n\nconfig :my_app, MyApp.Repo,\n  hostname: \"db12.dc0.comp.any\",\n  socket_options: [:inet6],\n  ...\n```\n\n## Supported Versions\n\n| Branch            | Support                  |\n| ----------------- | ------------------------ |\n| v3.12             | Bug fixes                |\n| v3.11             | Security patches only    |\n| v3.10             | Security patches only    |\n| v3.9              | Security patches only    |\n| v3.8              | Security patches only    |\n| v3.7 and earlier  | Unsupported              |\n\nWith version 3.0, Ecto API has become stable. Our main focus is on providing\nbug fixes and incremental changes.\n\n## Important links\n\n  * [Documentation](https://hexdocs.pm/ecto)\n  * [Mailing list](https://groups.google.com/forum/#!forum/elixir-ecto)\n  * [Examples](https://github.com/elixir-ecto/ecto/tree/master/examples)\n\n## Running tests\n\nClone the repo and fetch its dependencies:\n\n    $ git clone https://github.com/elixir-ecto/ecto.git\n    $ cd ecto\n    $ mix deps.get\n    $ mix test\n\nNote that `mix test` does not run the tests in the `integration_test` folder. To run integration tests, you can clone `ecto_sql` in a sibling directory and then run its integration tests with the `ECTO_PATH` environment variable pointing to your Ecto checkout:\n\n    $ cd ..\n    $ git clone https://github.com/elixir-ecto/ecto_sql.git\n    $ cd ecto_sql\n    $ mix deps.get\n    $ ECTO_PATH=../ecto mix test.all\n\n### Running containerized tests\n\nIt is also possible to run the integration tests under a containerized environment using [earthly](https://earthly.dev/get-earthly):\n\n    $ earthly -P +all\n\nYou can also use this to interactively debug any failing integration tests using:\n\n    $ earthly -P -i --build-arg ELIXIR_BASE=1.8.2-erlang-21.3.8.21-alpine-3.13.1 +integration-test\n\nThen once you enter the containerized shell, you can inspect the underlying databases with the respective commands:\n\n    PGPASSWORD=postgres psql -h 127.0.0.1 -U postgres -d postgres ecto_test\n    MYSQL_PASSWORD=root mysql -h 127.0.0.1 -uroot -proot ecto_test\n    sqlcmd -U sa -P 'some!Password'\n\n## Logo\n\n\"Ecto\" and the Ecto logo are Copyright (c) 2020 Dashbit.\n\nThe Ecto logo was designed by [Dane Wesolko](https://www.danewesolko.com).\n\n## License\n\nCopyright (c) 2013 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 [https://www.apache.org/licenses/LICENSE-2.0](https://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%2Fecto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felixir-ecto%2Fecto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felixir-ecto%2Fecto/lists"}