HOWTO use the very same CCDB for different databases
CCDB uses connection string to connect to databases. To use different databases with one installation of CCDB one should pass different connection string to it. So, here is how to do this.
1. Command line tools (CCDB CLI):
There are two ways of passing connection string to ccdb command:
- Use CCDB_CONNECTION environment variable
- '-c <connection string>' flag on ccdb start.
Flag '-c' has higher priority, so if one does next command, one is solid sure CCDB connects to db ONE:
> ccdb -i -c mysql://ONE_db_user@host/ONE
Thus one can create an alias:
alias ccdb_online="ccdb -c mysql://ONE_user@host/ONE"
Whenever ccdb_online is called, it connects to database ONE now.
To end up with the example, lets consider we have two databases ONE and TWO. If we have environment setup:
alias ccdb_online="ccdb -c mysql://ONE_user@host/ONE" export CCDB_CONNECTION=mysql://TWO_user@host/TWO Now if we call... > ccdb -i # connects to db TWO, because of CCDB_CONNECTION > ccdb_online -i # connects to ONE, because it is alias with '-c' flag
Without doubt one should be able even to call:
> ccdb -i -c sqlite:///some.file.db > ccdb_online -i -c sqlite:///some.file.db # SHOULD work too
Jana uses JANA_CALIB_URL environment variable. One has to set right connection string to this variable before JANA starts.
3. Language interfaces.
Language interfaces (C++ API, Python API and Java) API get connection string directly in factory function. Like:
Calibration* calib = CalibrationGenerator.Create("mysql://ONE_user@host/ONE",...)
So one just passes the right connection string to API.