In Slick is there a way to declar Tables without using a Specific JDBC Driver

空扰寡人 提交于 2019-12-24 15:53:40

问题


In my persistence code all through out the tables, etc. I have the following import

import scala.slick.driver.PostgresDriver.simple._

This is nice because it works, but this is a problem because all my code is bound to Postgres exclusively. If I want my production to do Postgres and my test to be HSQLDB, for example, I can't. I'd like to declare which DataSource/Driver when I'm running my persistence manager (which will do the create) instead of at the table declaration. What am I missing?


回答1:


This is certainly possible using the cake pattern. My team uses H2 in development and MySQL in production.

See MultiDBExample and MultiDBCakeExample in https://github.com/slick/slick-examples




回答2:


As far as I was able to find, I think this is a definite restriction in Slick. So much so that I dropped my test environments database and switched it to the same type as my production one. In retrospect, this is what I should have been doing in the first place, but I do understand this is sometimes easier said than done.



来源:https://stackoverflow.com/questions/24336441/in-slick-is-there-a-way-to-declar-tables-without-using-a-specific-jdbc-driver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!