SQLAlchemy helpers for working in Tornado
Project description
Python helpers for using SQLAlchemy with Tornado.
Installation
$ pip install tornado-sqlalchemy
Usage
>>> from tornado.gen import coroutine
>>> from tornado.web import Application, RequestHandler
>>> from tornado_sqlalchemy import as_future, make_session_factory, SessionMixin
>>>
>>> factory = make_session_factory('postgres://user:password@host/database')
>>>
>>> class MyRequestHandler(RequestHandler, SessionMixin):
... @coroutine
... def get(self):
... with self.make_session() as session:
... count = yield as_future(session.query(UserModel).count)
...
... self.write('{} users so far!'.format(count)
...
>>> app = Application(((r'/', MyRequestHandler),), session_factory=factory)
Documentation
Documentation is available at Read The Docs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for tornado_sqlalchemy-0.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 037ca6d95932876cd0a35e10de573ce4af2ad58eeb45f39cb49979b4554d0874 |
|
MD5 | 7989805f53e634678812cbd29fc8221f |
|
BLAKE2b-256 | ccb10a5634b1878c7d31c062904b7e69421dae336d2d8870aac9ae0e97137ff5 |