Skip to main content

SQLAlchemy helpers for working in Tornado

Project description

https://badge.fury.io/py/tornado-sqlalchemy.svg https://travis-ci.org/siddhantgoel/tornado-sqlalchemy.svg?branch=master https://readthedocs.org/projects/tornado-sqlalchemy/badge/?version=latest

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tornado_sqlalchemy-0.3.3.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

tornado_sqlalchemy-0.3.3-py2.py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page