Thank you for the quick and honest feedback

>From the test cases you provided, I can see if I modify my example to
use the Elixir session and metadata it will work.  (Provided as
reference below)

I assume I can somewhat easily refactor my legacy project to use the
Elixir session and metadata however it would be nice not to have to do
so.  (I'm not sure what the potential pitfalls might be yet)

Hal

----

import sqlalchemy as sa
import elixir

# use the elixir metadata and session
elixir.metadata.bind = "sqlite:///dummy.db"
from elixir import session as session
from elixir import metadata as metadata

# creating a table
people_table = sa.Table('people', metadata,
    sa.Column('person_id', sa.Integer, primary_key=True),
    sa.Column('name', sa.String(40))
)
people_table.create()

#create a holding class
class Person(object):
    def __repr__(self):
        return '%s(%r,%r)' % (
            self.__class__.__name__,self.name,self.person_id)

# map the holding class to the table definition
sa.orm.mapper(Person, people_table)

#create a Person
p1 = Person()
p1.name='Tommy'
session.add(p1)
session.commit()

# create an Elixir entity that relates back to Person class
class Pet(elixir.Entity):
    name = elixir.Field(elixir.String)
    owner = elixir.ManyToOne(Person)

elixir.setup_all(True)

# make a Pet and give it to the Person
d1 = Pet()
d1.name = 'Old Yeller'
d1.owner = p1
elixir.session.commit()


On May 24, 1:04 pm, Gaëtan de Menten <[email protected]> wrote:
> On Sun, 2010-05-23 at 11:00 -0700, hal_robertson wrote:
> > Hi there
>
> > I am just getting my feet wet with Elixir
>
> > I have a legacy app built with SqlAlchemy, and I'd like to add a few
> > new classes and database tables using Elixir
>
> > I do not want to rewrite the whole app to use Elixir right now.
>
> > In the meantime, I need to relate the new classes/tables created with
> > Elixir with the legacy classes/tables created with SqlAlchemy
>
> > How do I define the relationships in the Elixir classes so they will
> > recognize and play nicely with the SqlAlchemy mapped classes?
>
> The short answer is that currently you can't do that in all cases. It's
> on my TODO list, but given my current pace of development on Elixir
> (really, really slow), you shouldn't hope for it anytime soon.
>
> See what works and what doesn't 
> in:http://elixir.ematia.de/trac/browser/elixir/tags/0.7.1/tests/test_sa_...
>
> For a project like that I suggest you use SQLAlchemy's declarative
> extension instead.
>
> Hope it helps,
> Gaëtan.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "SQLElixir" 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 
> athttp://groups.google.com/group/sqlelixir?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"SQLElixir" 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/sqlelixir?hl=en.

Reply via email to