Mysql errors when using mssql

I’m trying to create an API that interfaces to a MS SQL database. My mix deps.get reports no errors or problems, but when I mix run --no-halt, I get a series of warnings about SQL and migrations (my app is a read-only app for an existing MS SQL database so I have no migrations).

How do I deal with this problem?

==> ecto
Compiling 70 files (.ex)
warning: redefining module Ecto.Adapters.MySQL (current version loaded from /Users/steve/Sites/ade_umbrella/_build/dev/lib/ecto_sql/ebin/Elixir.Ecto.Adapters.MySQL.beam)

warning: redefining module Ecto.Adapters.SQL.Stream (current version loaded from /Users/steve/Sites/ade_umbrella/_build/dev/lib/ecto_sql/ebin/Elixir.Ecto.Adapters.SQL.Stream.beam)

warning: redefining module Ecto.Adapter.Migration (current version loaded from /Users/steve/Sites/ade_umbrella/_build/dev/lib/ecto_sql/ebin/Elixir.Ecto.Adapter.Migration.beam)

warning: redefining module Ecto.Adapters.SQL.Sandbox (current version loaded from /Users/steve/Sites/ade_umbrella/_build/dev/lib/ecto_sql/ebin/Elixir.Ecto.Adapters.SQL.Sandbox.beam)

warning: redefining module Ecto.Migration.Runner (current version loaded from /Users/steve/Sites/ade_umbrella/_build/dev/lib/ecto_sql/ebin/Elixir.Ecto.Migration.Runner.beam)

warning: redefining module Ecto.Adapters.SQL.Sandbox.Connection (current version loaded from /Users/steve/Sites/ade_umbrella/_build/dev/lib/ecto_sql/ebin/Elixir.Ecto.Adapters.SQL.Sandbox.Connection.beam)

warning: redefining module Ecto.Migration.SchemaMigration (current version loaded from /Users/steve/Sites/ade_umbrella/_build/dev/lib/ecto_sql/ebin/Elixir.Ecto.Migration.SchemaMigration.beam)

== Compilation error in file lib/ecto/adapters/mysql.ex ==
** (FunctionClauseError) no function clause matching in Keyword.fetch!/2    
    The following arguments were given to Keyword.fetch!/2:
        # 1
        # 2
    Attempted function clauses (showing 1 out of 1):
        def fetch!(keywords, key) when is_list(keywords) and is_atom(key)
    (elixir) lib/keyword.ex:390: Keyword.fetch!/2
    lib/ecto/adapters/mysql.ex:118: (module)
    (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6

Here is my mix deps declaration:

  defp deps do
      {:jason, "~> 1.0"},
      {:mssql_ecto, "~> 1.2.0"},
      {:mssqlex, "~> 1.1.0"},
      {:poison, "~> 3.0"},
      {:plug, "~> 1.8"},
      {:cowboy, "~> 2.7"},

Not sure why it’s calling to MYSQL (not mssql), maybe you should check the Repo configuration for the adapter. It should be

config :my_app, MyApp.Repo,
adapter: MssqlEcto

(it seems to be MySql)

FYI, I had a similar use case (read only) and I’ve avoided using ecto (another dependency), and I just used raw sql queries from mssqlex. It was way simpler for this case. Maybe it’s a good idea also for you?

My Repo is like this, but your idea would work, I’ll think about doing that.

defmodule TwApi.Repo do
  use Ecto.Repo,
    otp_app: :tw_api,
    adapter: Ecto.Adapters.MssqlEcto


But it’s still calling to the mysql adapter… have you checked your config files?

I’ve been checking EVERY file - not a MySQL anywhere!?!?
It seems to be something that elixir is adding in ‘after the fact’…

Maybe as default, when no config was set… :man_shrugging:

Please check your mix.lock which version of ecto got pulled in. Perhaps we can use that information to narrow things down.

"ecto": {:hex, :ecto, "2.2.12", "ce7f619c1451daad0f59e8f01fd8e2584226171dc273e3346444446a13d93943", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"},