Sorry, yea, it's supported.   And it should be documented, but it's not.

There are two places where you should look.   The AppConfig object has
a setup_sqlalchemy method that does the actuall setup, the __init__ of
your model has the module level wiring, and the init_model function is
guaranteed to run after the model is setup, and the engines are bound.

It would be nice for us to present this to people in a little bit
easier package, but baring that we should definitely post a recipe for
it.

On Thu, Jun 4, 2009 at 12:31 PM, Mike Driscoll<[email protected]> wrote:
>
> Hi,
>
> According to Mark Ramm's blog, supporting multiple databases is
> supposed to be easy (see
> http://compoundthinking.com/blog/index.php/2008/07/31/10-reasons-why-the-new-turbogears-2-alpha-is-worth-a-look/).
> So where is the documentation that says how to do it??
>
> I "think" I need to put multiple sqlalchemy.url's in my
> development.ini file. But where oh where do I set up the SA engines
> at? The model's __init__ claims to support multiple databases too
> using MetaData, but it doesn't show where to bind the engine unless
> you're supposed to use the undocumented init_model function somehow.
>
> I'm pretty sure the init_model came from Perkins. Maybe he can tell me
> where to put my call to the function and how to set it up for multiple
> databases?
>
> That would be great!
>
> Thanks,
>
> Mike
>
>
> On May 28, 12:47 pm, Mike Driscoll <[email protected]> wrote:
>> Hi,
>>
>> I am having a little trouble wrapping my head around how to configure
>> my model's __init__.py file for multiple databases. I am working on an
>> application that accesses 3 databases and does reflection on select
>> tables from all three.
>>
>> I assume I need to comment out this line:
>>
>> metadata = DeclarativeBase.metadata
>>
>> and instead create three metadata instances based on MetaData(),
>> correct?
>>
>> Finally, as I understand it, I can use the "init_model" function to do
>> the mapping for some of them, but I am not understanding where to
>> create the engine object to pass to it. Also, once I have my tables
>> mapped in the function, what do I put in my real model file if
>> anything?
>>
>> Hopefully that stuff makes sense. I am using Python 2.5 and TG2 in a
>> virtualenv on Windows XP.
>>
>> Thanks!
>>
>> Mike
> >
>



-- 
Mark Ramm-Christensen
email: mark at compoundthinking dot com
blog: www.compoundthinking.com/blog

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to