diff options
author | Michael Trier <mtrier@gmail.com> | 2009-03-31 22:31:08 +0000 |
---|---|---|
committer | Michael Trier <mtrier@gmail.com> | 2009-03-31 22:31:08 +0000 |
commit | 6010afb28f95c7050ca48ddd2e6f65ca6cbae5a1 (patch) | |
tree | 46259c03c209a89702c32c939c8ea035edee9425 /examples/elementtree/optimized_al.py | |
parent | 832ea82fefa366f4717e889511f66ecfce3313de (diff) | |
download | sqlalchemy-6010afb28f95c7050ca48ddd2e6f65ca6cbae5a1.tar.gz |
Lots of fixes to the code examples to specify imports explicitly.
Explicit imports make it easier for users to understand the examples.
Additionally a lot of the examples were fixed to work with the changes in the
0.5.x code base. One small correction to the Case expression. Thanks a bunch
to Adam Lowry! Fixes #717.
Diffstat (limited to 'examples/elementtree/optimized_al.py')
-rw-r--r-- | examples/elementtree/optimized_al.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/examples/elementtree/optimized_al.py b/examples/elementtree/optimized_al.py index 8b50f6805..39d35921a 100644 --- a/examples/elementtree/optimized_al.py +++ b/examples/elementtree/optimized_al.py @@ -6,8 +6,9 @@ which joins on only three tables. """ ################################# PART I - Imports/Configuration ########################################### -from sqlalchemy import * -from sqlalchemy.orm import * +from sqlalchemy import (MetaData, Table, Column, Integer, String, ForeignKey, + Unicode, and_) +from sqlalchemy.orm import mapper, relation, create_session, lazyload import sys, os, StringIO, re @@ -21,8 +22,7 @@ logging.basicConfig() #logging.getLogger('sqlalchemy.engine').setLevel(logging.DEBUG) -from elementtree import ElementTree -from elementtree.ElementTree import Element, SubElement +from xml.etree import ElementTree meta = MetaData() meta.bind = 'sqlite://' @@ -166,14 +166,14 @@ session = create_session() for file in ('test.xml', 'test2.xml', 'test3.xml'): filename = os.path.join(os.path.dirname(sys.argv[0]), file) doc = ElementTree.parse(filename) - session.save(Document(file, doc)) + session.add(Document(file, doc)) print "\nSaving three documents...", line session.flush() print "Done." # clear session (to illustrate a full load), restore -session.clear() +session.expunge_all() print "\nFull text of document 'text.xml':", line document = session.query(Document).filter_by(filename="test.xml").first() |