I"m wondering if this module could make it easy to grab info from an external DB and create a view from it?

Comments

mikeryan’s picture

Assigned: Unassigned » mikeryan
Category: feature » support

Can you be a little more explicit? You can implement a hook for copying data from an external database into your default database, and Table Wizard will make it available to views. If what you mean is to surface the data while it's still in the external database, that isn't currently supported but I'm thinking about it.

frankcarey’s picture

+1 to being able to link to an external database. It would be much easier than having to import the external DB with the internal one everytime it gets updated. If the external is constantly being updated this is even more difficult.

Any ideas on how you'd get the external to link in? (i know this feature request is not trivial)

mikeryan’s picture

It's going to be a challenge, Views won't handle it out-of-the-box (at least, it won't let a table in an external DB be a base table) - but we need this for a current project, so we'll find a way to get it done.

qbnflaco’s picture

Would DBTNG in d7 make this easier to implement? If it is, maybe we can save time by building it with this in mind, so it doesn't have to totally rewritten for d7. Just a thought.

mikeryan’s picture

The dependency here is on Views, not the core database API. Moshe has picked up some ideas on how to do this, I'll be seeing what I can do with them soon.

mikeryan’s picture

I'm actively working on supporting data from external DBs this week. Status:

  • The Schema module, which does the table inspection our analysis feature depends on, does not currently support external databases. I've submitted a patch (#411538).
  • Views actually does support using a table from an external database as a base table.
  • I suspect that relationships among tables in the same external database will work just fine.
  • I am 99.9% certain that relationships between tables in different databases will not work - this will be the hard part.

I hope to have all but the last (hard) part committed within a day or two.

frankcarey’s picture

excellent! Seems that relationships between tables of different databases wouldn't be as critical. Will the id mapping still work (or is that a migrate module thing?)

mikeryan’s picture

Relationships between tables in different databases is critical for the project I'm being paid for right now...

The migrate module ID mapping shouldn't be affected.

I may be jumping the gun, but I've just committed a first draft of this support - I'd appreciate feedback on the behaviour and presentation. You need to define your external DB in $db_url - its tables will appear in the list. Relationships across DBs won't work at all - relationships between tables in an external DB can be created with a bit of pain:

  1. Start view with one external table as the base.
  2. Add a couple of fields from that table, then add the relationship.
  3. Save your view now!
  4. Try adding fields from the right-hand table to the view - things blow up.
  5. Come back to the view - the fields actually were added, and seem to work fine.

The problem seems to be with displaying field options for fields in the second table...

Thanks.

mikeryan’s picture

Status: Active » Needs review

Update: the problem is a known bug in Views - apply the patch (#380560: Fatal error: Call to a member function get_handlers()) and joining external tables within a DB works just fine.

mikeryan’s picture

Status: Needs review » Fixed

A week without problems being reported, time to move on...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.