Multiple Databases
Torque can access multiple databases from within one Torque instance.
Basically this means that Torque's inbuilt connection handling can handle
more than one database connection pool.
There are three different scenarios for multiple databases,
with different levels of support from Torque:
-
Each table has a unique name; different tables belong to different
databases. This situation is fully supported by the Torque runtime.
If the generated peer classes (generated by the torque generator
using the torque templates) are used, the different databases are
handled automatically in the standard cases because each table has
a default database to which it belongs.
-
Some or all table names are not unique (there are tables with the
same name in different databases), and the tables with the same
name have the same structure (same column names and data types etc).
This situation is also fully supported by the Torque runtime.
However, the generated peer classes are not generated for this
situation; meaning that by default, a connection for querying and
saving is always opened to the default database for the given table
name.
This means you will either need to pass the correct database handle name
for querying and saving, or not use the connection handling
provided by the peer classes.
-
Some or all table names are not unique (there are tables with the
same name in different databases), and some of the tables with the same
name have a different structure than other tables with the same name.
This situation is not recommended, it is unclear to which extent it is
supported.
The configuration of multiple databases is similar to the configurations
described in the section
initialisation and configuration,
however you will need to define more than one database handle.