2015-06-22 25 views
1

我剛剛創建了一個Luminus應用程序,它有兩個單獨的地方定義數據庫訪問。在project.clj的拉格泰姆:如何使用Luminus連接到Heroku中的PostgreSQL?

: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"}) 

有沒有人寫過代碼,以打破DATABASE_URL的Heroku提供,或以某種方式使用它爲了連接?當然,我不是第一個想要這樣做的人,對吧?

此外,在這個過程中,爲開發和生產提供單獨的憑證將是很好的。

回答

0

如果ragtime正在使用clojure.java.jdbc(我相信它),那麼你應該可以直接將DATABASE_URL傳遞給它。如A位:

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

有關更多示例,請參閱Heroku Dev CenterGetting Started guides

相關問題