Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

haoflynet/tornado-sqlalchemy

 
 

Repository files navigation

tornado-sqlalchemy

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.

Development

To work on this package, please make sure you have a working Python installation on your system.

  1. Create a virtualenv - python -m venv venv && source venv/bin/activate.
  2. Git clone the repository - git clone https://github.com/siddhantgoel/tornado-sqlalchemy
  3. Install the packages required for development - pip install -r requirements/3.txt (or 2.txt if you're on Python 2)
  4. Install this package - pip install ..
  5. You should now be able to run the test suite - py.test tests/.

About

Python helpers for using SQLAlchemy with Tornado

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%