【问题标题】:How to connect to PostgreSQL in Heroku with Luminus?如何使用 Luminus 连接 Heroku 中的 PostgreSQL?
【发布时间】:2015-06-22 15:44:37
【问题描述】:

我刚刚创建了一个 Luminus 应用程序,它有两个不同的地方定义了数据库访问。在 ragtime 的 project.clj 中:

:ragtime {:migrations ragtime.sql.files/migrations
          :database "jdbc:postgresql://localhost/foobar?user=db_user_name_here&password=db_user_password_here"}

在 src/foobar/db/core.clj:

(def db-spec
  {:subprotocol "postgresql"
   :subname "//localhost/foobar"
   :user "db_user_name_here"
   :password "db_user_password_here"})

有没有人编写过代码来分解 Heroku 提供的 DATABASE_URL,或者以某种方式将其用于连接?当然,我不是第一个想要这样做的人,对吧?

此外,在此过程中,最好有单独的开发和生产凭证。

【问题讨论】:

    标签: postgresql heroku clojure luminus


    【解决方案1】:

    如果 ragtime 正在使用 clojure.java.jdbc(我相信是),那么您应该能够直接将 DATABASE_URL 传递给它。有点像:

    (def spec (or (System/getenv "DATABASE_URL") "postgresql://localhost:5432/shouter"))
    

    有关更多示例,请参阅 Heroku Dev CenterGetting Started guides

    【讨论】:

      猜你喜欢
      • 2012-06-07
      • 1970-01-01
      • 2014-04-06
      • 2021-10-21
      • 1970-01-01
      • 1970-01-01
      • 2014-06-26
      • 2016-03-28
      • 2018-10-16
      相关资源
      最近更新 更多