From 6010afb28f95c7050ca48ddd2e6f65ca6cbae5a1 Mon Sep 17 00:00:00 2001 From: Michael Trier Date: Tue, 31 Mar 2009 22:31:08 +0000 Subject: 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. --- examples/elementtree/optimized_al.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'examples/elementtree/optimized_al.py') 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() -- cgit v1.2.1