phildeman has asked for the wisdom of the Perl Monks concerning the following question:

Does anyone know if DBIx::Class can query multiple databases simultaneously?

Meaning I have data in a MySQL table and data in a SQL Server table. If DBIx::Class is unable to query from different databases, has anyone queried data from different databases, using a different methodology?

  • Comment on DBIx::Class Querying Multiple Databases

Replies are listed 'Best First'.
Re: DBIx::Class Querying Multiple Databases
by locked_user sundialsvc4 (Abbot) on May 19, 2014 at 18:10 UTC

    You will open a database “connection” by calling the connect() method of the Schema-object, as shown in the documentation page for DBIx::Class.   This connection-handle (called $schema in the docs) is what you will use when talking to that particular database.   Your application may open several database connections and perform queries and other operations against any of them, at will.

Re: DBIx::Class Querying Multiple Databases
by Laurent_R (Canon) on May 19, 2014 at 20:42 UTC
    Sure, you can. I have done it quite a few times: reading from one DB to write to another, or reading from two DBs to compare the data, etc.

    Although, as far as I can remember, when I did it, it was always DBs of the same type (using two Oracle DBs, or two mySQL DBs, but not a mix), I cannot see any reason why it would not work with DBs of different brands or from different providers, at least not in general (there might be some very specific cases where it does not work smoothly, but I can't think of any such case).

Re: DBIx::Class Querying Multiple Databases
by Anonymous Monk on May 19, 2014 at 18:09 UTC
    answer (near the end of the section "Getting started")