Elixir无法连接到PostgreSQL

时间:2019-04-12 01:57:34

标签: postgresql elixir phoenix-framework

我在本地计算机上使用以下项目运行

Erlang with openssl: Version 18.0
Elixir: Version 1.3.4

我使用 asdf 安装了它们。一切正常。但是当我尝试连接数据库时,总是会出现以下错误:

  

未处理的退出,位于GET / ad_units / Y9Gd1kAiPCv8WOrE   退出于::gen_server.call(#PID <0.469.0>,{:checkout,#Reference <0.0.6.2529>,true,15000},5000)       **(退出)引发了异常:           **(CaseClauseError)没有大小写子句匹配:[10、7、7、18、4、1]               (postgrex)lib / postgrex / utils.ex:39:Postgrex.Utils.parse_version / 1               (postgrex)lib / postgrex / extensions / void.ex:5:Postgrex.Extensions.Void.init / 2               (postgrex)lib / postgrex / types.ex:56:Postgrex.Types.prepare_extensions / 2中的匿名fn / 2               (elixir)lib / enum.ex:1115:Enum.into / 3中的匿名fn / 4               (elixir)lib / enum.ex:1623:枚举。“-reduce / 3-lists ^ foldl / 2-0-” / 3               (elixir)lib / enum.ex:1121:Enum.into / 4               (postgrex)lib / postgrex / protocol.ex:434:Postgrex.Protocol.bootstrap_send / 3               (postgrex)lib / postgrex / protocol.ex:69:Postgrex.Protocol.connect / 1               (db_connection)lib / db_connection / connection.ex:114:DBConnection.Connection.connect / 2               (连接)lib / connection.ex:623:Connection.enter_connect / 5               (stdlib)proc_lib.erl:239 :: proc_lib.init_p_do_apply / 3

我正在使用Ubuntu 18.04和PostgreSQL 10。 顺便说一句,我可以使用Ruby on Rails项目连接到postgres,并且工作正常。我尝试先删除build,然后再删除mix deps.get && mix deps.compile,但还是一样。

任何主意是什么问题?

更新

mix.deps依赖项:

defp deps do
    [{:phoenix, "~> 1.1.6"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_ecto, "~> 2.0"},
      {:phoenix_html, "~> 2.4"},
      {:phoenix_live_reload, "~> 1.0"},
      {:gettext, "~> 0.9"},
      {:cowboy, "~> 1.0"},
      {:phoenix_slime, "~> 0.6.0"},
      {:timex, "~> 2.2"},
      {:tzdata, "~> 0.1.8", override: true},
      {:timex_ecto, "~> 1.1.3"},
      # {:quantum, ">= 1.7.1"},
      {:exrm, "~> 1.0" },
      {:edeliver, ">= 1.2.10"},
      {:browser, "~> 0.1.0"}]
  end

1 个答案:

答案 0 :(得分:0)

我将postgres版本从10.7降级到9.5。就像魅力一样!

项目中使用的postgrex适配器版本没有升级以连接到 PostgreSQL 9.5版。

也许将来会帮助别人。

感谢@AlekseiMatiushkin的评论。