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.3.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5273af378bb723d519bc392a1e5e74552c3b7f812ffc2b1e2e8b24b35d04e6bd |
|
MD5 | faad4201d7f4d34d7d80e7527982018b |
|
BLAKE2b-256 | 2fe113d1a40c9714b97da2fdcaa6c92a43c0ae81515c06c96effc26aed735e0c |