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.

Activity (RSS)

Tuesday, January 14 2014
190 Invalid json is returned for json column type was updated
  • Daniele Varrazzo
    Daniele Varrazzo commented at 5:26 PM

    @fog: I was going to give Oleg your suggestion, and I just realized that psycopg2.extras.register_default_json(loads=lambda x: x) works as well but is much more...

  • Daniele Varrazzo
    Daniele Varrazzo commented at 5:22 PM

    Yes. The easiest is:

    >>> psycopg2.extras.register_default_json(loads=lambda x: x)
    >>> cur.execute("select %s::json", [Json({u'Url': u'€'})])
    >>> cur.fetchone()...
  • Federico Di Gregorio
    Federico Di Gregorio commented at 5:20 PM

    Just create and register a type-caster that returns JSON as text:

    JSONTEXT = psycopg2.extensions.new_type((114,), "JSONTEXT", (lambda value, curs: value))
    psyc...
  • Federico Di Gregorio
    Federico Di Gregorio edited a comment at 5:21 PM

    Just create and register a type-caster that returns JSON as text:

    JSONTEXT = psycopg2.extensions.new_type((114,), "JSONTEXT", (lambda value, curs: value))
    psyc...
  • Oleg Anashkin
    Oleg Anashkin commented at 4:55 PM

    I peeked into psycopg's code and found that inside register_json it always creates typecasters to perform loads/dumps on the column data, therefore unpacking th...

15 earlier changes…
  • Federico Di Gregorio
    Federico Di Gregorio commented at 4:52 PM

    @extesy, yes, I forgot that the result is a tuple even when you select just one column. See my edited answer.

  • Oleg Anashkin
    Oleg Anashkin commented at 4:48 PM

    deleted

  • Oleg Anashkin
    Oleg Anashkin edited a comment at 4:48 PM

    deleted

  • Oleg Anashkin
    Oleg Anashkin commented at 4:03 PM

    Ok, so as I understand the problem is that the json record is actually eval'd by psycopg instead of being converted to text, right? Similar to what Daniele was ...

  • Oleg Anashkin
    Oleg Anashkin edited a comment at 4:04 PM

    Ok, so as I understand the problem is that the json record is actually eval'd by psycopg instead of being converted to text, right? Similar to what Daniele was ...

  • Federico Di Gregorio
    Federico Di Gregorio commented at 3:58 PM

    That's just how Python formats a dictionary in a "print". If you try to access it you'll see that it is a perfectly valid:

    record = cur.fetchone()
    print record...
  • Federico Di Gregorio
    Federico Di Gregorio edited a comment at 4:52 PM

    That's just how Python formats a dictionary in a "print". If you try to access it you'll see that it is a perfectly valid:

    record = cur.fetchone()
    print record...
  • Oleg Anashkin
    Oleg Anashkin commented at 3:50 PM

    And here is repro using python:

    import psycopg2
    
    conn = psycopg2.connect(database='ebooktracker')
    cur = conn.cursor()
    cur.execute("select properties from book ...
  • Oleg Anashkin
    Oleg Anashkin commented at 3:45 PM

    Sorry, fixed formatting:

    ebooktracker=# \d+ book;
                                                                  Table "public.book"
          Column       |       ...
  • Oleg Anashkin
    Oleg Anashkin commented at 3:45 PM

    I'm sorry, but this is json and I got it from postgres. Attaching screenshot. Column type is json. Here is the table schema:

    ebooktracker=# \d+ book;
    Table "pub...

  • Daniele Varrazzo
    Daniele Varrazzo commented at 3:38 PM

    I'm using psycopg through https://github.com/coleifer/peewee ORM, but it doesn't mess with the data. The column in question is defined as a simple text field. ...

  • Oleg Anashkin
    Oleg Anashkin commented at 3:23 PM

    I'm using psycopg through https://github.com/coleifer/peewee ORM, but it doesn't mess with the data. The column in question is defined as a simple text field. W...

  • Daniele Varrazzo
    Daniele Varrazzo commented at 11:15 AM

    Psycopg only forwards what received by postgres. How are you generating this data?

    From a quick test postgres can't generate "wrong" data:

    piro=# select '{''Ur...
  • Oleg Anashkin
    Oleg Anashkin commented at 4:00 AM

    Sorry, somehow bug post got screwed up. What I meant is this: {'Url': 'blablabla'} - uses single quotes.

  • Psycopg website
    Psycopg website created the ticket at 3:58 AM

    Submitted by: Oleg Anashkin

    For columns with type json, psycopg returns string with single quotes, like this:

    {'Url': 'http://www.amazon.com'}

    This is inval...

Tuesday, January 07 2014
188 assertion failed in pqpath.c was updated
  • Daniele Varrazzo
    Daniele Varrazzo commented at 5:12 PM

    A script to reproduce the issue would be preferred. A patch to fix the issue would be even better accepted, above all if checking the issue implies recompiling ...

  • Edouard Chamillard
    Edouard Chamillard commented at 4:47 PM

    the trace was indeed produced by a debug version of python. originally gdb pointed to pqpath.c:1140 which is Py_INCREF(cast);

    i can try to reproduce the issue a...

  • Daniele Varrazzo
    • State changed from new to open
    by Daniele Varrazzo at 4:38 PM

    I've not been able to reproduce the issue, although I've run psycopg test suite againts Python 3.3.

    I don't think the block you have reported is the correct one...

189 execute & mogrify don't fail with no format placeholder but with arguments given was updated
  • Daniele Varrazzo
    • Milestone set to psycopg3
    by Daniele Varrazzo at 5:02 PM

    About problem 1: if the query contains no placeholder I'd argue it should also allow an empty list as argument (it is a sequence with the same number of item as...

psycopg3 was created by Daniele Varrazzo at 5:02 PM
 
3 of 3 tickets remain in this milestone
Monday, December 30 2013
189 execute & mogrify don't fail with no format placeholder but with arguments given was created
  • Grégory Starck
    Grégory Starck created the ticket at 10:16 AM

    Hi,

    I realized that cursor.{execute,mogrify} do accept not-empty arguments (either dict or tuple) while the query string has no format placeholder :

    >>> sys.ve...
Tuesday, December 24 2013
188 assertion failed in pqpath.c was updated
  • Edouard Chamillard
    Edouard Chamillard commented at 3:33 PM

    for reference this is the relevant pqpath.c code block

            /* else if we got binary tuples and if we got a field that
               is binary use the default ...
  • Edouard Chamillard
    Edouard Chamillard created the ticket at 3:32 PM

    rel-2.5.1 os-linux

    celery tasks are using psycopg through sqlalchemy from two different machines. on one it works fine, on the other it segfaults. after a bit o...

  • Edouard Chamillard
    Edouard Chamillard edited the ticket at 3:34 PM

    rel-2.5.1 os-linux

    celery tasks are using psycopg through sqlalchemy from two different machines. on one it works fine, on the other it segfaults. after a bit o...

Monday, December 09 2013
180 Return number of rows for copy operations was updated
Wednesday, November 27 2013
187 lobject (conn) can segfault with bad parameter was updated
  • Voicu
    Voicu commented at 1:36 PM

    Hmm, I now see I'm on an earlier version actually (2.4.5)

    >>> import psycopg2.extensions as ex
    >>> ex.cursor([])
    <cursor object at 0x00000000026B9B40; closed: ...
  • Daniele Varrazzo
    • State changed from open to resolved
    by Daniele Varrazzo at 12:45 PM
  • Daniele Varrazzo
    Daniele Varrazzo commented at 12:06 PM

    Really? It doesn't seem so:

    >>> cur = psycopg2.extensions.cursor([])
    TypeError: argument 1 must be psycopg2._psycopg.connection, not list
    
  • Voicu
    Voicu commented at 11:30 AM

    Hmm, I tested what happens when doing psycopg2.extensions.cursor(<not a conn object>) and the result is weird - the cursor object is created and it lets you do ...

  • Voicu
    Voicu edited a comment at 11:34 AM

    Hmm, I tested what happens when doing psycopg2.extensions.cursor(<not a conn object>) and the result is weird - the cursor object is created and it lets you do ...

3 earlier changes…
  • Voicu
    Voicu edited a comment at 11:38 AM

    Hmm, I tested what happens when doing psycopg2.extensions.cursor(<not a conn object>) and the result is weird - the cursor object is created and it lets you do ...

  • Voicu
    Voicu edited a comment at 11:39 AM

    Hmm, I tested what happens when doing psycopg2.extensions.cursor(<not a conn object>) and the result is weird - the cursor object is created and it lets you do ...

  • Daniele Varrazzo
    • State changed from new to open
    by Daniele Varrazzo at 11:17 AM

    Thank you for the report. Args should be parsed using O! instead of O. See cursor_init() for an example.

Tuesday, November 26 2013
187 lobject (conn) can segfault with bad parameter was created
  • Psycopg website
    Psycopg website created the ticket at 6:38 PM

    Submitted by: Voicu Hodrea

    attempting to create an lobject but giving a wrong parameter (something which is not a connection object) will segfault python

Monday, October 21 2013
181 Arrays of INET type not properly parsed into a list was updated
  • Daniele Varrazzo
    • State changed from new to invalid
    by Daniele Varrazzo at 2:13 PM

    Please follow the new_array_type example to see how to create a generic array type caster.

    >>> cur.execute("select '{127.0.0.1,10.10.1.16}'::inet[]")
    >>> prin...
  • Daniele Varrazzo
    Daniele Varrazzo edited a comment at 2:13 PM

    Please follow the new_array_type example to see how to create a generic array type caster.

    >>> cur.execute("select '{127.0.0.1,10.10.1.16}'::inet[]")
    >>> prin...
163 Range types doesn't support infinity [now,infinity) was updated
  • Daniele Varrazzo
    Daniele Varrazzo commented at 1:18 PM

    Thank you for the tip, will fix the docs.

  • Alex Morega
    Alex Morega commented at 1:05 PM

    InfDateAdapter.getquoted should return a bytestring in Python 3, but this is not obvious from the documentation, and the stack trace is kind of cryptic. I think...

Wednesday, October 16 2013
178 Psycopg2 Win Installer Not Working for 32-bit install on 64-bit machine was updated
174 server side curosr scrolling out of bound does not raise any Exception (os-li... was updated
  • Daniele Varrazzo
    • State changed from open to hold
    by Daniele Varrazzo at 5:46 PM

    I've tried implementing this feature, but is more problematic than expected, because what returned by MOVE is actually contrived. Well, it's actually easy, but ...

186 Error on install psycopg2 in OS X 10.9 mavericks was updated
  • Daniele Varrazzo
    Daniele Varrazzo commented at 3:41 PM

    Well, the sequence of import is relatively easy:

    psycopg/error_type.c -> psycopg/psycopg.h -> <Python.h> -> pyerrors.h
    

    it's up to you to understand why this d...

  • Thiago Avelino
    Thiago Avelino commented at 3:18 PM

    avelino@avelino ~/Dropbox/avelino/projects/y/jpfm/src (master) $ grep -r PyBaseExceptionObject /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versio...

  • Daniele Varrazzo
    Daniele Varrazzo commented at 1:49 PM

    Sorry: PyBaseExceptionObject is defined in pyerrors.h.

    $ grep -r PyBaseExceptionObject /usr/include/python2.7
    /usr/include/python2.7/pyerrors.h:} PyBaseExcepti...
167 Problem with %, (, ) in names of parameters in cursor.execute was updated
  • Daniele Varrazzo
    • State changed from open to resolved
    by Daniele Varrazzo at 2:37 PM

    Issue solved by declaring in the docs that %, (, ) are not supported.

173 Return a meaningful message on async connection error was updated
  • Daniele Varrazzo
    • State changed from open to resolved
    by Daniele Varrazzo at 2:29 PM

    Fixed in my 2.5 branch, to be released in 2.5.2