Since you're using `defdb`, the code is evaluated when the namespace is
loaded. We've handled this by calling `create-db` and `default-connection`
directly in at least one of our services:

https://github.com/cyverse/DE/blob/master/services/apps/src/apps/kormadb.clj

Another option is to call `defdb` inside a function:

https://github.com/cyverse/DE/blob/master/tools/facepalm/src/facepalm/core.clj#L185-L201

You can also skip defining the symbol, which will avoid linter warnings:

https://github.com/cyverse/DE/blob/master/services/saved-searches/src/saved_searches/config.clj#L20-L38

Dennis


On Thu, Jun 9, 2016 at 3:49 AM 'Simon Brooke' via Korma <
[email protected]> wrote:

> This ought to be simple, but I haven't (yet) worked out how to do it, and
> I'm sure someone else must have solved it.
>
> I'm writing a little tool which does analysis of history databases written
> by our systems in the field; the databases are (typically, not always) held
> in Microsoft SQL Server instances on different machines. In future there
> may also be Postgres instances. Currently I'm declaring the database as
> follows:
>
> (db/defdb fpphistory {:subprotocol "jtds:sqlserver"
>                :subname "//127.0.0.1//history"
>                :user "sgs-historian"
>                :password "xxxxxxxxx"})
>
> which works fine in development, but in production the tool will rarely or
> never run on the machine the DBMS sits on, and although the name of the
> database is currently always 'history', this also won't necessarily always
> be true in future.
>
> I've got a -main function in which I already parse command line arguments.
> I'd like to pass in the sub-protocol, the host address, the database name,
> the username and the password as command line arguments. Any suggestions as
> to how I do this?
>
> Any help gratefully received!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Korma" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Korma" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to