summaryrefslogtreecommitdiff
path: root/examples/sharding
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/sharding
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/sharding')
-rw-r--r--examples/sharding/attribute_shard.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/examples/sharding/attribute_shard.py b/examples/sharding/attribute_shard.py
index 0a9e992a3..45a019f13 100644
--- a/examples/sharding/attribute_shard.py
+++ b/examples/sharding/attribute_shard.py
@@ -18,8 +18,9 @@ To set up a sharding system, you need:
"""
# step 1. imports
-from sqlalchemy import *
-from sqlalchemy.orm import *
+from sqlalchemy import (create_engine, MetaData, Table, Column, Integer,
+ String, ForeignKey, Float, DateTime)
+from sqlalchemy.orm import sessionmaker, mapper, relation
from sqlalchemy.orm.shard import ShardedSession
from sqlalchemy.sql import operators
from sqlalchemy import sql
@@ -27,10 +28,10 @@ import datetime
# step 2. databases
echo = True
-db1 = create_engine('sqlite:///shard1.db', echo=echo)
-db2 = create_engine('sqlite:///shard2.db', echo=echo)
-db3 = create_engine('sqlite:///shard3.db', echo=echo)
-db4 = create_engine('sqlite:///shard4.db', echo=echo)
+db1 = create_engine('sqlite://', echo=echo)
+db2 = create_engine('sqlite://', echo=echo)
+db3 = create_engine('sqlite://', echo=echo)
+db4 = create_engine('sqlite://', echo=echo)
# step 3. create session function. this binds the shard ids
@@ -195,6 +196,6 @@ assert t.reports[0].temperature == 80.0
north_american_cities = sess.query(WeatherLocation).filter(WeatherLocation.continent == 'North America')
assert [c.city for c in north_american_cities] == ['New York', 'Toronto']
-asia_and_europe = sess.query(WeatherLocation).filter(WeatherLocation.continent.in_('Europe', 'Asia'))
+asia_and_europe = sess.query(WeatherLocation).filter(WeatherLocation.continent.in_(['Europe', 'Asia']))
assert set([c.city for c in asia_and_europe]) == set(['Tokyo', 'London', 'Dublin'])