the 2 approaches are code 2 db or db 2 code; 
yours is db 2 code - AFAIK see sqlsoup 
http://www.sqlalchemy.org/docs/05/plugins.html#plugins_sqlsoup

On Friday 05 September 2008 07:23:35 Sam wrote:
> Michael...
>
> I've read the tutorial, and I think I understand it.
>
> But maybe I don't understand reflection.  I thought that I could
> use it to avoid defining anything.  I'd like to have objects
> basically spring into life knowing exactly what their row names
> are, without having to type anything.
>
> Am I misunderstanding reflection?  Can it not automatically figure
> out the row names for me?  If it can, is there an example of this
> somewhere?
>
> Or should I just sit down and type out all my classes with
> rownames?
>
> Thanks
>
> On Sep 4, 5:02 pm, Michael Bayer <[EMAIL PROTECTED]> wrote:
> > On Sep 4, 2008, at 7:16 PM, Sam wrote:
> > > I woke up today and decided it was time to switch one of my
> > > simpler programs from sqlobject to sqlalchemy.
> > >
> > > I'm using reflection.   After some googling I was able to find
> > > a way to insert:
> > > mp = mphones.insert().execute(word=word, mphone=phone)
> > >
> > > The above works okay.
> > >
> > > But I'd rather be able to do something like this:
> > > mp = mphones(word=word, mphone=phone)
> > > sess.add(mp)
> > >
> > > Unfortunately I couldn't make that work.
> > >
> > > Here's the setup code I'm using:
> > > from sqlalchemy import *
> > > from sqlalchemy.orm import sessionmaker
> > >
> > > engine = create_engine("postgres://postgres:[redacted]/mydb")
> > > meta = MetaData()
> > > meta.bind = engine
> > >
> > > Session = sessionmaker(bind=engine)
> > > sess = Session()
> > >
> > > mphones = Table('mphones', meta, autoload=True)
> >
> > Table isnt going to cut it alone; you'd have to use mappers.
> >  Read   through the ORM tutorial and you'll get a sense of how to
> > do that. I'd recommend using declarative_base() to set things up
> > which is what the tutorial uses most of the way.
>
> 


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

Reply via email to