[storm] 【Storm】How does Storm do to works very well connecting to several databases ?
James Henstridge
james at jamesh.id.au
Tue Aug 26 02:37:34 BST 2008
2008/8/26 刘建敏 <szu_ljm at 163.com>:
>
>
>
> Hi everybody :
> I don't understand "Storm works very well connecting to several
> databases and using the same Python types (or different ones) with all of
> them. " How does Storm do ? Can you give me a example ?
Lets say you have two databases that share the same schema but have
different data. You can define a single class (lets say Foo) that
represents one of the tables in the schema, and use it to represent
rows from either database. Something like:
class Foo(object):
__storm_table__ = "foo"
id = Int(primary=True)
....
store1 = Store(create_database("postgres:database1"))
store2 = Store(create_database("postgres:database2"))
foo1 = store1.get(Foo, 42)
foo2 = store2.get(Foo, 42)
The point here is that the class "Foo" is not bound to a particular
database connection. Instead, instances of "Foo" are bound to
database connections. So "foo1" and "foo2" are distinct objects.
> If now , I want use memcache , does it work ? how can i use it ?
We don't have any direct support for memcached. You'd probably have
to implement support for it on top of Storm somewhere in your app.
James.
More information about the storm
mailing list