I was wondering if it is possible to switch between different databases on one Drupal installation.

I have a different DB which another application uses it. Both DB are on the same server (localhost) and I was wondering if it is possible to temporarily connect to that DB in order to READ and WRITE data from/to it, using Drupal.

1 Answer 1


You can, of course, use the database API that comes with PHP.

To use Drupal's database API, configure your databases as described in How to connect to multiple databases within Drupal and use db_set_active() to switch between databases.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.