table.c.id.default = Sequence('some_sequence')    seems to work.

Thanks

On May 12, 4:01 pm, Michael Bayer <[email protected]> wrote:
> you really shouldnt be using the "useexisting" flag - any configuration in 
> the Table you give is ignored, since the Table is already constructed.    
> This is less than ideal and perhaps "useexisting" should be made private, 
> since its mainly needed for the internals of the reflection process.
>
> because we've only started having really good support for Oracle very 
> recently, the Sequence thing is an issue we haven't delved into deeply.   I 
> would suggest seeing what happens if you take an existing table and just say 
> table.c.id.default = Sequence("some_sequence"), which should do the job but 
> im not 100% sure.
>
> On May 12, 2010, at 5:47 AM, GHZ wrote:
>
>
>
>
>
> > Hi,
>
> > Can I make the second form (metadata.reflect, then Table with
> > useexising=True), result in the same insert statement as the first
> > form (Table with autoload=True)?
>
> > Thanks.
>
> > from sqlalchemy import create_engine, Table, Column, Sequence,
> > MetaData, Integer
>
> > engine = create_engine('oracle://fred:f...@mig01')
> > ddls = [
> >    """drop table customer""",
> >    """create table customer (
> >        id   number primary key,
> >        name varchar2(10)
> >       )""",
> > ]
>
> > for ddl in ddls:
> >    try:
> >        print ddl,
> >        engine.execute(ddl)
> >        print 'ok'
> >    except:
> >        print 'fail'
> >        pass
>
> > # First form is OK
> > # results in: INSERT INTO bob (id, name) VALUES
> > (bob_sq.nextval, :name) RETURNING bob.id INTO :ret_0
> > metadata = MetaData(bind=engine)
> > t = Table('bob', metadata, Column('id', Integer, Sequence('bob_sq'),
> > primary_key=True), autoload=True)
> > print t.insert().values(name='bob')
>
> > # Second form NOT OK
> > # results in: INSERT INTO bob (name) VALUES (:name)
> > metadata = MetaData()
> > metadata.reflect(bind=engine, only=['bob'])
> > t = Table('bob', metadata, Column('id', Integer, Sequence('bob_sq'),
> > primary_key=True), useexisting=True)
> > print t.insert().values(name='bob')
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "sqlalchemy" 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/sqlalchemy?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" 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/sqlalchemy?hl=en.

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

Reply via email to