Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm extending Table Wizard to support exposing tables in external databases to Views (see #402968). Since Table Wizard depends on the schema module's inspection feature to analyze tables, I've extended it to handle this - patch attached. Basically, the inspect hooks now inspect the active database rather than always using the default database; it's up to the caller to call db_set_active first.
Comment | File | Size | Author |
---|---|---|---|
#4 | schema-support-external-dbs-411538-4.patch | 2.7 KB | webchick |
#3 | schema-support-external-dbs-411538-3.patch | 2.5 KB | webchick |
#2 | schema-external2.patch | 1.83 KB | mikeryan |
schema-external.patch | 1.63 KB | mikeryan | |
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman commentedCould you elaborate on what the code below means? Maybe use the variable name $prior_db_name? It looks like you are just changing to 'default' and then reverting to whatever you had before.
Comment #2
mikeryanAdded clarification
Comment #3
webchickWow, that's so ghetto that there's no other way to get the current DB connection's name. :\ I can confirm though; I tried global $db_active, $db_url, etc. Nothing works. I really hope this is better in D7.
Comments:
Updated patch that attempts to take these things into account. The code seems like a sensible addition to me, though, and I can confirm it fixes #402968: Read from external DB?.
Comment #4
webchickAttempt #2.
This just calls db_set_active() without the 'default' parameter (since that's the default), which makes the code a bit easier to understand. Also tweaked the comments accordingly.
Comment #5
alex_b CreditAttribution: alex_b commentedI am using this patch with table wizard and it works flawless. Did not test with PostGreSQL but the changes aren't PostGreSQL specific.
Comment #6
Shai CreditAttribution: Shai commented#5 marked this as, "reviewed & tested by the community". Which of these patches is it referring to? The original, webchick's from #4?, Seems like webchick's improvements are improvements... but what is the process here?
Shai
Comment #7
mikeryanI've committed webchick's patch.