Tornado with ORM??

538 views
Skip to first unread message

HENG ZHOU

unread,
Jul 29, 2010, 12:55:25 AM7/29/10
to python-tornado
Hi, all:

As a framework, I think tornado should add a ORM between DB and model. It is boring to write the RAW sql query string.

here are some tips about my options:

1. the ORM must be simple and simple to use. It just contains only some files.
2. It looks like the Django ORM, but more simple than Django.


EN, I hope Tornado will be best!



Ilya kut

unread,
Jul 29, 2010, 1:02:50 AM7/29/10
to python-...@googlegroups.com
If Django ORM isn't fit then maybe sql alchemy?
You can use just any python ORM with tornado.

Matt Ferguson

unread,
Jul 29, 2010, 1:15:27 AM7/29/10
to python-...@googlegroups.com, python-...@googlegroups.com
Yes, check out SQLAlchemy or Elixir (which sits on top of SQLAlchemy). Both are well documented, relatively simple to use, powerful, and will work with Tornado. I'm sure somebody would be glad to set up and example project for you.

Sent from my iPhone

Mariano Garcia Berrotarán

unread,
Jul 29, 2010, 1:27:15 AM7/29/10
to python-...@googlegroups.com
I'm using Canonical's storm with tornado. (storm.canonical.com) and it
does the job =D

--
Mariano García Berrotarán

HENG ZHOU

unread,
Jul 29, 2010, 3:18:10 AM7/29/10
to python-...@googlegroups.com
Hi Guys:

I know that SQLAlchemy or SQLobject and so on. But what I mean is that the Tornado as a framework, it should contain a ORM framework....

isn't it ??




2010/7/29 Mariano Garcia Berrotarán <garcia.b...@gmail.com>

David P. Novakovic

unread,
Jul 29, 2010, 3:27:13 AM7/29/10
to python-...@googlegroups.com

Pylons uses sqlalchemy, django uses the django orm, rails uses active record, grails uses hibernate.

They all allow you to use sql too...

Use which ever python orm you like...

On 29/07/2010 5:18 PM, "HENG ZHOU" <ourwa...@gmail.com> wrote:

Hi Guys:

I know that SQLAlchemy or SQLobject and so on. But what I mean is that the Tornado as a framework, it should contain a ORM framework....

isn't it ??




2010/7/29 Mariano Garcia Berrotarán <garcia.b...@gmail.com>


>
> I'm using Canonical's storm with tornado. (storm.canonical.com) and it
> does the job =D
>

> On...



Juan J.

unread,
Jul 29, 2010, 3:29:55 AM7/29/10
to python-...@googlegroups.com
El jue, 29-07-2010 a las 15:18 +0800, HENG ZHOU escribió:
> Hi Guys:
>
> I know that SQLAlchemy or SQLobject and so on. But what I mean is that
> the Tornado as a framework, it should contain a ORM framework....
>
> isn't it ??

It's not a big deal. You can use any ORM you want.

In fact I think that's one of the brilliant points of Tornado: it
doesn't get in your way. So go and use anything you want ;)

Cheers,

Juanjo

--
jjm's home: http://www.usebox.net/jjm/
blackshell: http://blackshell.usebox.net/
ramble on: http://rambleon.usebox.net/

Claudio Freire

unread,
Jul 29, 2010, 10:44:17 AM7/29/10
to python-...@googlegroups.com


2010/7/29 Juan J. <rei...@usebox.net>

El jue, 29-07-2010 a las 15:18 +0800, HENG ZHOU escribió:
> Hi Guys:
>
> I know that SQLAlchemy or SQLobject and so on. But what I mean is that
> the Tornado as a framework, it should contain a ORM framework....
>
> isn't it ??

It's not a big deal. You can use any ORM you want.

In fact I think that's one of the brilliant points of Tornado: it
doesn't get in your way. So go and use anything you want ;)

Not only that, I've seen somewhere that there's an "asynchronous" version of sqlalchemy.
However that works (haven't had a chance to use it yet).

So sqlalchemy (in its asynchronous form) would be a nice match with Tornado (not so much with other - synchronous - orms).

Phil Plante

unread,
Jul 29, 2010, 10:50:52 AM7/29/10
to Tornado Web Server
I agree on keeping Tornado lean and mean. Its great because its close
to bare metal and lets you build upon it, rather than forcing your
project into its mold. Don't add extra fluff features many of us have
already found elsewhere.

Any ORM will never be as flexible as a native query format. That
aside I quite like being able to drop in mongoengine or sql alchemy as
I see fit.

On Jul 29, 9:44 am, Claudio Freire <klaussfre...@gmail.com> wrote:
> 2010/7/29 Juan J. <reid...@usebox.net>

Arek Bochinski

unread,
Jul 29, 2010, 11:56:47 AM7/29/10
to python-...@googlegroups.com
Well, this topic fits well into what Tornado tries to accomplish. On one hand, it is marketed as a web server.
Additionally, it has added modules for templates, auth, mysqldb and such that make it more complete than
just a socket request server. These additions allow for a quick start, but on the other hand don't offer
luxuries of heavily integrated frameworks like Django, Pylons, whatever, and for a good reason.
Honestly, it can't be both a server and a framework while satisfying the majority.

My guess is that Tornado will and should remain a simple core. Every other piece or module that isn't
directly tied to serving HTTP shouldn't be part of it. Let's call these external pieces 'extensions'.

So you would have Tornado(core) with web, ioloop, httpserver and client . And then all those sugar-coating
extensions that allow for any 'X' functionality, such as Tornado-Orm, Tornado-Auth, Tornado-* ... but in regular case,
and going back to the original request for an ORM, it should just SQLAlchemy or Storm or whatever.

my two cents

Brian Jones

unread,
Jul 29, 2010, 2:50:40 PM7/29/10
to python-...@googlegroups.com
The fact that Tornado *doesn't* include an ORM is, in fact, a feature. If it included one, we'd all be arguing about how Tornado's ORM sucks compared to X instead of how to make Tornado better. Then we'd see all these projects that attempt to replace the Tornado ORM with X, and we'd see questions on the mailing list from folks who think their non-working hacked-in-place ORM is a Tornado problem. Meanwhile, if they just leave things as they are, you can use the ORM that best fits your needs, or (like me, mostly) none at all.

Let those other conversations take place elsewhere (can you tell I've used Django?).

brian
--
Brian K. Jones
My Blog          http://www.protocolostomy.com
Follow me      http://twitter.com/bkjones

HENG ZHOU

unread,
Jul 29, 2010, 10:38:12 PM7/29/10
to python-...@googlegroups.com
Sorry guys, Maybe I just hope Tornado will be better and so I throw my opinions out.

Now, the discuss have renewed my thinking about Tornado. Yes! it must be simple and just like a core, and more it is pythonic. This is the only reason why we all love it. HAHA.

Thank so many guys for telling me so much things behind Tornado. It is thinking beyong programing. Stay hungry, stay foolish. Thank you all.




2010/7/30 Brian Jones <bkj...@gmail.com>



--
--------------------------------------------------------------------
周衡  HengZhou
# 搜狐博客开发前端工程师 
# SOHU Blog UED Team
---------------------------------------------------------------------
--

Narayanaperumal Gurusamy

unread,
Mar 18, 2014, 12:29:48 PM3/18/14
to python-...@googlegroups.com, garcia.b...@gmail.com
Hi Mariano,

    May i know how did you configured with tornado? Is it working as async? Can you please share some code snippets if you have?

Thanks
Narayanaperumal Gurusamy

Yutong Zhao

unread,
Mar 18, 2014, 1:48:20 PM3/18/14
to python-...@googlegroups.com, garcia.b...@gmail.com
It's actually very difficult to make an asynchronous ORM client. See this, by the author of SQLAlchemy himself:

http://stackoverflow.com/questions/16491564/how-to-make-sqlalchemy-in-tornado-to-be-async

For us (Stanford's Folding@home project), we rolled our own ORM for redis pipelined up the whazoo. We wanted to use an ORM since no one wants to deal with manual clean up of keys for lookups, relations, (redis has no support for log(N) lookups, so we just store the reverse lookups directly with O(1) lookup time but pay the price in O(N) extra space to store the reverse lookup keys)

For everything else we use raw Mongo queries via the async Motor driver, developed by Jesse, who frequents this forum fairly often.

Mark Biggers

unread,
Apr 12, 2014, 11:27:59 AM4/12/14
to python-...@googlegroups.com
Yutong, would you identify what repo(s) of your Folding@home code, contain the Redis ORM?   Sounds like it could be very useful, especially split-out as a module/library.   Thank you.

Kyle Kelley

unread,
Apr 12, 2014, 1:22:20 PM4/12/14
to python-...@googlegroups.com, Ash Wilson
Not sure if others would be interested in it, but I've been experimenting with a bridge between SQLAlchemy and Momoko.

Design goal is:

* Write your models with SQLAlchemy
* When finished creating a query compile the statement to raw SQL

dialect = sqlalchemy.dialects.postgres.dialect()
raw_sql = unicode(query.statement.compile(dialect=dialect)

* Use that raw SQL with momoko's fairly clean async setup
* From momoko's results, create the SQLAlchemy objects

I've called it MomokoYokoOhNo for now (https://github.com/rgbkrk/MomokoYokoOhNo). The OhNo is because this might be fundamentally a bad idea (function call overhead from using SQLAlchemy, general overengineering). I haven't pushed anything to master and have largely been sticking things in a prototype branch.

If any are interested, I'm more than happy to collab on it through, issues, email and pull requests. It's been kind of an on and off project/interest, but if there's interest I'll have back at it.

-- Kyle



--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornad...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aliane Abdelouahab

unread,
Apr 12, 2014, 5:20:03 PM4/12/14
to python-...@googlegroups.com
Mongotor (another mongodb driver for tornado) uses an ORM
https://github.com/marcelnicolay/mongotor
Reply all
Reply to author
Forward
0 new messages