README.md (3160B)
1 Ecto SQL 2 ========= 3 4 [![Build Status](https://github.com/elixir-ecto/ecto_sql/workflows/CI/badge.svg)](https://github.com/elixir-ecto/ecto_sql/actions) 5 6 Ecto SQL ([documentation](https://hexdocs.pm/ecto_sql)) provides building blocks for writing SQL adapters for Ecto. It features: 7 8 * The Ecto.Adapters.SQL module as an entry point for all SQL-based adapters 9 * Default implementations for Postgres (Ecto.Adapters.Postgres), MySQL (Ecto.Adapters.MyXQL), and MSSQL (Ecto.Adapters.Tds) 10 * A test sandbox (Ecto.Adapters.SQL.Sandbox) that concurrently runs database tests inside transactions 11 * Support for database migrations via Mix tasks 12 13 To learn more about getting started, [see the Ecto repository](https://github.com/elixir-ecto/ecto). 14 15 ## Running tests 16 17 Clone the repo and fetch its dependencies: 18 19 $ git clone https://github.com/elixir-ecto/ecto_sql.git 20 $ cd ecto_sql 21 $ mix deps.get 22 $ mix test.all 23 24 Note that `mix test.all` runs the tests in `test/` and the `integration_test`s for each adapter: `pg`, `myxql` and `tds`. 25 26 You can also use a local Ecto checkout if desired: 27 28 $ ECTO_PATH=../ecto mix test.all 29 30 You can run tests against a specific Ecto adapter by using the `ECTO_ADAPTER` environment variable: 31 32 $ ECTO_ADAPTER=pg mix test 33 34 MySQL and PostgreSQL can be installed directly on most systems. For MSSQL, you may need to run it as a Docker image: 35 36 docker run -d -p 1433:1433 --name mssql -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=some!Password' mcr.microsoft.com/mssql/server:2017-latest 37 38 ### Running containerized tests 39 40 It is also possible to run the integration tests under a containerized environment using [earthly](https://earthly.dev/get-earthly): 41 42 $ earthly -P +all 43 44 You can also use this to interactively debug any failing integration tests using the corresponding commands: 45 46 $ earthly -P -i --build-arg ELIXIR_BASE=1.8.2-erlang-20.3.8.26-alpine-3.11.6 --build-arg MYSQL=5.7 +integration-test-mysql 47 $ earthly -P -i --build-arg ELIXIR_BASE=1.8.2-erlang-20.3.8.26-alpine-3.11.6 --build-arg MSSQL=2019 +integration-test-mssql 48 $ earthly -P -i --build-arg ELIXIR_BASE=1.8.2-erlang-20.3.8.26-alpine-3.11.6 --build-arg POSTGRES=11.11 +integration-test-postgres 49 50 Then once you enter the containerized shell, you can inspect the underlying databases with the respective commands: 51 52 PGPASSWORD=postgres psql -h 127.0.0.1 -U postgres -d postgres ecto_test 53 MYSQL_PASSWORD=root mysql -h 127.0.0.1 -uroot -proot ecto_test 54 sqlcmd -U sa -P 'some!Password' 55 56 ## License 57 58 Copyright (c) 2012 Plataformatec \ 59 Copyright (c) 2020 Dashbit 60 61 Licensed under the Apache License, Version 2.0 (the "License"); 62 you may not use this file except in compliance with the License. 63 You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) 64 65 Unless required by applicable law or agreed to in writing, software 66 distributed under the License is distributed on an "AS IS" BASIS, 67 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 68 See the License for the specific language governing permissions and 69 limitations under the License.