summaryrefslogtreecommitdiff
path: root/examples/elementtree/pickle.py
diff options
context:
space:
mode:
authorMichael Trier <mtrier@gmail.com>2009-03-31 22:31:08 +0000
committerMichael Trier <mtrier@gmail.com>2009-03-31 22:31:08 +0000
commit6010afb28f95c7050ca48ddd2e6f65ca6cbae5a1 (patch)
tree46259c03c209a89702c32c939c8ea035edee9425 /examples/elementtree/pickle.py
parent832ea82fefa366f4717e889511f66ecfce3313de (diff)
downloadsqlalchemy-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/pickle.py')
-rw-r--r--examples/elementtree/pickle.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/examples/elementtree/pickle.py b/examples/elementtree/pickle.py
index e7cd86984..53d2ee2b6 100644
--- a/examples/elementtree/pickle.py
+++ b/examples/elementtree/pickle.py
@@ -6,8 +6,9 @@ structure in distinct rows using two additional mapped entities. Note that the
styles of persistence are identical, as is the structure of the main Document class.
"""
-from sqlalchemy import *
-from sqlalchemy.orm import *
+from sqlalchemy import (create_engine, MetaData, Table, Column, Integer, String,
+ PickleType)
+from sqlalchemy.orm import mapper, create_session
import sys, os
@@ -20,7 +21,7 @@ logging.basicConfig()
# uncomment to show SQL statements and result sets
#logging.getLogger('sqlalchemy.engine').setLevel(logging.DEBUG)
-from elementtree import ElementTree
+from xml.etree import ElementTree
engine = create_engine('sqlite://')
meta = MetaData(engine)
@@ -53,11 +54,11 @@ doc = ElementTree.parse(filename)
# save to DB
session = create_session()
-session.save(Document("test.xml", doc))
+session.add(Document("test.xml", doc))
session.flush()
# clear session (to illustrate a full load), restore
-session.clear()
+session.expunge_all()
document = session.query(Document).filter_by(filename="test.xml").first()
# print