1. Using Elixir, how do I connect to two different databases at the
same time? I can see that I need two different metadata instances,
and somehow have to associate the right metadata instance with the
right tables, but I don't see how yet. An example of how to do this
would be great.
2. I'd like to use 'use_options(autoload=True)' with several tables
in an existing database, where the tables have pre-existing
relationships. I know that Elixir is supposed to handle this, and
generate the relationships on the Entity class instances. How do I
know what names Elixir has assigned to both ends of the relationship
between two tables?
You'd probably also need two ``engine``s (one per DB). Then, assuming
your ``metadata``s are dynamic you'd do this:
metadata_1.connect(engine_1)
metadata_2.connect(engine_2)
Or you could use ``BoundMetaData``s and bind them to your ``engine``s
up front and not need call ``connect``.
Elixir ships with a default ``DynamicMetaData`` (elixir.metadata), but
you don't have to use it. You can create your own ``metadata``s and
then use ``using_options(metadata=my_metadata)`` when declaring your
``Entity``s.
Hope that helps a little,
__wyatt
Actually, that helps a lot. Thanks.
> 2. I'd like to use 'use_options(autoload=True)' with several tables
> in an existing database, where the tables have pre-existing
> relationships. I know that Elixir is supposed to handle this, and
> generate the relationships on the Entity class instances. How do I
> know what names Elixir has assigned to both ends of the relationship
> between two tables?
I think you are mistaken. Elixir supports autoloaded tables, but
doesn't generate relationships between tables. See
http://elixir.ematia.de/svn/elixir/trunk/tests/test_autoload.py
for an example.
By the way, the autoload feature is still a bit experimental. In
version 0.2.0, it doesn't support has_and_belongs_to_many
relationships. Many improvements were made in the trunk but it's still
not quite perfect (it fails on self-referencial
has_and_belongs_to_many relationships).
--
Gaëtan de Menten
http://openhex.org