summaryrefslogtreecommitdiff
path: root/examples/custom_attributes/custom_management.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-04-27 17:21:31 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-04-27 17:21:31 -0400
commit8cdb4543bd7a85bef0286433576aafe0fb8e7c4c (patch)
tree4f69b10e11a0cb6e58f0bab326a534b7dbcd12f8 /examples/custom_attributes/custom_management.py
parent5f51d409ccda1033a41256dfc28e46bc6923521d (diff)
downloadsqlalchemy-8cdb4543bd7a85bef0286433576aafe0fb8e7c4c.tar.gz
modernize some more examples
Diffstat (limited to 'examples/custom_attributes/custom_management.py')
-rw-r--r--examples/custom_attributes/custom_management.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/examples/custom_attributes/custom_management.py b/examples/custom_attributes/custom_management.py
index 12b745db6..2199e0138 100644
--- a/examples/custom_attributes/custom_management.py
+++ b/examples/custom_attributes/custom_management.py
@@ -64,7 +64,8 @@ class MyClass(object):
if __name__ == '__main__':
- meta = MetaData(create_engine('sqlite://'))
+ engine = create_engine('sqlite://')
+ meta = MetaData()
table1 = Table('table1', meta,
Column('id', Integer, primary_key=True),
@@ -73,7 +74,7 @@ if __name__ == '__main__':
Column('id', Integer, primary_key=True),
Column('name', Text),
Column('t1id', Integer, ForeignKey('table1.id')))
- meta.create_all()
+ meta.create_all(engine)
class A(MyClass):
pass
@@ -82,7 +83,7 @@ if __name__ == '__main__':
pass
mapper(A, table1, properties={
- 'bs':relationship(B)
+ 'bs': relationship(B)
})
mapper(B, table2)
@@ -92,7 +93,7 @@ if __name__ == '__main__':
assert a1.name == 'a1'
assert a1.bs[0].name == 'b1'
- sess = Session()
+ sess = Session(engine)
sess.add(a1)
sess.commit()