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(SessionMixin, RequestHandler):
... @coroutine
... def get(self):
... with self.make_session() as session:
... count = yield as_future(session.query(UserModel).count)
...
... # OR count = self.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.
Development
To work on this package, please make sure you have a working Python installation on your system.
Create a virtualenv -
python -m venv venv && source venv/bin/activate
.Git clone the repository -
git clone https://github.com/siddhantgoel/tornado-sqlalchemy
Install the packages required for development -
pip install -r requirements/3.txt
(or 2.txt if you’re on Python 2)Install this package -
pip install .
.You should now be able to run the test suite -
py.test tests/
.
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.4.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb29a82ea63120623ca326e8445f9cc2f36d3029e3ea24d5b35aa5ac92ea893e |
|
MD5 | 7224766f598f8c9edf343171ee795fa7 |
|
BLAKE2b-256 | 2d016ad75dd3b81736f739e2a34f7aee83566a957e3fafaa55ede3d6d376553a |