Comments (5)
Hi Chen,
Thanks for the report.
As a quick check, can you try this cursor class with plain psycopg2 in your
environment?
On Apr 26, 2014 8:13 PM, "Chen Tao" [email protected] wrote:
Greetings. As the title suggests, getconn() doesn't play well with
NamedTupleCursor.Here's a test case:
import psycopg2
import momoko
from psycopg2.extras import NamedTupleCursor
from tornado.testing import AsyncTestCase, gen_test
import unittest
import osclass ConnNamedTuple(AsyncTestCase):
def setUp(self):
super().setUp()
self.db = momoko.Pool(
dsn='dbname=dbdb user=%s host=localhost port=5432' % os.environ['USER'],
size=3,
ioloop=self.io_loop,
callback=self.stop,
cursor_factory=NamedTupleCursor
)
self.wait()def tearDown(self): self.db.close() self.io_loop.close() @gen_test def test_conn_namedtuple(self): yield momoko.Op(self.db.getconn)
unittest.main()
Here's the stack trace:
ERROR: test_conn_namedtuple (main.ConnNamedTuple)
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/tornado/testing.py", line 427, in wrapper
functools.partial(f, self), timeout=timeout)
File "/usr/local/lib/python3.4/dist-packages/tornado/ioloop.py", line 389, in run_sync
return future_cell[0].result()
File "/usr/local/lib/python3.4/dist-packages/tornado/concurrent.py", line 129, in result
raise_exc_info(self.**exc_info)
File "", line 3, in raise_exc_info
File "/usr/local/lib/python3.4/dist-packages/tornado/gen.py", line 206, in handle_exception
if runner is not None and runner.handle_exception(typ, value, tb):
File "/usr/local/lib/python3.4/dist-packages/tornado/gen.py", line 580, in handle_exception
self.run()
File "/usr/local/lib/python3.4/dist-packages/tornado/gen.py", line 529, in run
yielded = self.gen.throw(_exc_info)
File "tmp/conn_namedtuple.py", line 26, in test_conn_namedtuple
yield momoko.Op(self.db.getconn)
File "/usr/local/lib/python3.4/dist-packages/tornado/stack_context.py", line 302, in wrapped
ret = fn(_args, kwargs)
File "/usr/local/lib/python3.4/dist-packages/momoko/connection.py", line 594, in io_callback
self.callback(None)
File "/usr/local/lib/python3.4/dist-packages/momoko/connection.py", line 640, in _ping_callback
cursor.fetchall()
File "/usr/local/lib/python3.4/dist-packages/psycopg2/extras.py", line 317, in fetchall
nt = self.Record = self._make_nt()
File "/usr/local/lib/python3.4/dist-packages/psycopg2/extras.py", line 340, in _make_nt
return namedtuple("Record", [d[0] for d in self.description or ()])
File "/usr/lib/python3.4/collections/__init.py", line 338, in namedtuple
'identifiers: %r' % name)
ValueError: Type names and field names must be valid identifiers: '?column?'
Ran 1 test in 0.031s
FAILED (errors=1)
I'm on Python 3.4. pip freeze output, all are PyPI releases.
Momoko==1.1.2
psycopg2==2.5.2
tornado==3.2I think it's easy to workaround but it's a little bit annoying. Thanks in
advance.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/74
.
from momoko.
You're right it's the same problem with psycopg2. I'm closing this and will report there. Thanks!
from momoko.
this is actually momoko's error
cur.execute("SELECT 'ok';")
need to be:
cur.execute("SELECT 'ok' as blah;")
if you used NamedTupleCursor.
AND, the error occured at connection.py
line 635
cursor.execute("SELECT 1")
and i modified it to
cursor.execute("SELECT 1 as ping")
which temp fixed.
from momoko.
You are right - this is a real bug.
from momoko.
Hello! It seems like the same error exists with register_hstore():
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/tornado/ioloop.py", line 565, in _run_callback
ret = callback()
File "/usr/local/lib/python3.4/dist-packages/tornado/stack_context.py", line 275, in null_wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/momoko/connection.py", line 864, in _register
oid, array_oid = cursor.fetchone()
File "/usr/local/lib/python3.4/dist-packages/psycopg2/extras.py", line 303, in fetchone
nt = self.Record = self._make_nt()
File "/usr/local/lib/python3.4/dist-packages/psycopg2/extras.py", line 340, in _make_nt
return namedtuple("Record", [d[0] for d in self.description or ()])
File "/usr/lib/python3.4/collections/__init__.py", line 348, in namedtuple
raise ValueError('Encountered duplicate field name: %r' % name)
ValueError: Encountered duplicate field name: 'oid'
I guess it is needed to use aliases as in this issue on this line:
https://github.com/FSX/momoko/blob/master/momoko/connection.py#L890
from momoko.
Related Issues (20)
- momoko makes IOError in ioloop HOT 3
- Behavior of .execute() wo parameters does not match psycopg2 HOT 1
- code in ConnectionContainer.all_dead conflicts with Pool.putconn HOT 4
- The future returned by Connection.execute will never resolve HOT 1
- self.conns.empty() in Pool.close will not work as expected by big chance HOT 3
- How can I run the first sample of momoko HOT 6
- Pool fails to reconnect when using Unix-domain socket (OperationalError: server closed the connection unexpectedly) HOT 18
- Restarting PostgreSQL sometimes causes Pool.getconn() to hang HOT 5
- Momoko Pool trying to use dead connections HOT 3
- Writing tests for tornado app, which uses momoko for postgres DB. HOT 2
- Cannot add momoko HOT 1
- Please help me figure out why this code freezes forever HOT 8
- Any suggestion on how I'd commit/rollback using a connection pool? HOT 3
- when using RealDictCursor, Pool.register_json error HOT 2
- Typo in connection.py (socker instead of socket) HOT 2
- error if trying to connect pool while Postgress is not online HOT 2
- NamedTupleCursor factory test is executed even if MOMOKO_TEST_HSTORE is disabled HOT 1
- Debian packaging HOT 1
- AttributeError: 'Future' object has no attribute 'set_exc_info' HOT 5
- Not worked with python 3.7 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from momoko.