Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

connect(cursor_factory=NamedTupleCursor) seems broken

#211

Greetings. As the title suggested, NamedTupleCursor doesn't work well when passing into connect(). Here's a test case:

import psycopg2
from psycopg2.extras import NamedTupleCursor

conn = psycopg2.connect("dbname=collective user=collective", cursor_factory=NamedTupleCursor)
cur = conn.cursor()
cur.execute("SELECT 'ok';")
print(cur.fetchone())

I'm on Python3.4, psycopg2==2.5.2. Thanks in advance!

Reported by jagt · April 27th, 2014 @ 01:56 AM

State: invalid
Milestone: none
Assigned to: nobody

Activity

  1. Daniele Varrazzo
    Daniele Varrazzo
    • State changed from new to invalid

    The error is pretty obvious:

    ValueError: Type names and field names can only contain alphanumeric characters and underscores: '?column?'
    

    if you want to use a named tuple why don't you give a damn name to your fields?

    cur.execute("SELECT 'ok' as blah;")
    print(cur.fetchone())
    Record(blah='ok')
    

    April 30th, 2014 @ 04:34 PM