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 at
http://groups.google.com/group/sqlalchemy?hl=en.