FSX / momoko

Wraps (asynchronous) Psycopg2 for Tornado.
http://momoko.61924.nl/
Other
363 stars 73 forks source link

'connection_factory' argument doesn't work #63

Closed riaqn closed 10 years ago

riaqn commented 10 years ago

Here is a sample

import tornado.gen
import tornado.ioloop
import momoko
from psycopg2.extras import RealDictConnection, RealDictCursor

@tornado.gen.coroutine
def query():
    db = momoko.Pool('dbname=jvhua user=jvhua', connection_factory=RealDictConnection)
    cur = yield momoko.Op(db.execute, 'SELECT * FROM users;')
    print(cur.fetchone())

tornado.ioloop.IOLoop.instance().run_sync(query)
tornado.ioloop.IOLoop.instance().start()

What it prints is a tuple, while expected a dict.If I add cursor_factory=RealDictCursor to momoko.Op, things work fine.

haizaar commented 10 years ago

Thanks for your bug report. Can you please open a separate issue regarding cursor_factory in Pool()?

Regarding your problem - can you please try with this branch: https://github.com/haizaar/momoko (master)

Thanks.

riaqn commented 10 years ago

I have tried haizaar/momoko, problem is the same. Using psycopg2-2.5.2 , tornado 3.2 on python 3.3.3, Maybe helps.