-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define Datasource Options with Environment Variables #52
Comments
We seemed to have solved the problem by using 'memoize' like so: (defn datasource-options []
{:jdbc-url (str "jdbc:oracle:" (env :db-subname))
:user (env :db-user)
:password (env :db-password)})
(defn datasource []
(hikari/make-datasource (datasource-options)))
(def datasource-memo
(memoize datasource)) Then we can use 'datasource-memo' like so: (jdbc/with-db-connection [conn {:datasource (datasource-memo)}]
(jdbc/query conn
... Everything appears to work fine: Let me know if this is a non-approved way of using hikari-cp. |
@jscruggs if it works for you... it's OK :) Maybe a good idea would be to update the README to describe the usage. Would you be so kind and prepare a PR? :) |
Thanks for taking the time to file the issue @jscruggs.
The options map you pass to
Let's take a closer look at this problem. Are you sure that the Let us know. A minimal test case allowing us to reproduce the issue against an open source database would be wonderful. Cheers! |
Closing due to inactivity. |
We are encountering an issue where we can't compile our project because we are using environment variables to set the database password, username, and jdbc-url in def datasource-options. Turning the database-options and database defs into functions cause the following error when we run our test suite:
Oddly enough, some of the tests that hit the database pass while later tests in the run return the above error.
Here is our code (calls to 'env' are using 'environ' to get environment variables):
Do the datasource-options and datasource defs need to be defs? If so, how do we avoid hardcoding sensitive information (passwords) into our applications and for use in different environments?
The text was updated successfully, but these errors were encountered: