I'm building a website using Yesod and Persistent (I'm using the basic yesod mysql scaffolding).
I need to access a different database that the main one, but runDB
uses
the default connection parameter and connection. Is there a simple way to use Persistent with two different connection parameters ?
Looking at the scaffolded code, it should be easy to define another rundDB
accessing another pool created with different connection parameters. This implies to also modify the Settings
to read and stote the extra connection info.
However, one of the main issue is, one needs to remember which connection (or wich runDB
) to use depending on the data type to load. Another solution is to use federated tables.
MySql (or MariaDB) allows to create a proxy table connected to a remote database. Even though it needs a some setup, this as the advantage to be safe and easier to use on the client side.