Re: JSON type caster - Mailing list psycopg

From Tobias Oberstein
Subject Re: JSON type caster
Date
Msg-id 505899EF.3010909@gmail.com
Whole thread Raw
In response to Re: JSON type caster  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
Responses Re: JSON type caster
List psycopg
Hi Daniele,

I will work on the ticket .. need to read into docs/tests habits with
Psycopg2 first.

 > What should we do as an extension? There is no such a thing as a
> Python json object. I think we should provide a thin wrapper similar
> to psycopg2.Binary, that would be used:
>
>      from psycopg2.extensions import Json
>      data = {'my': ["stuff"]}
>      cur.execute("insert ...", [Json(data)])
>

That sounds reasonable and looks like it fits well with Psycopg design.

Personally, I am mainly calling stored procedures, i.e.

select proname, prorettype, proargtypes from pg_proc where proname =
'create_employee';

create_employee,114,114

=> a SP which takes 1 JSON arg, and has return type JSON.

The return type casting is taken care of by the (new) SQL=>Py JSON caster.

The argument type isn't handled automatically.

Given the stuff above (Json() thin wrapper), I still need to determine
the input arg type from pg_proc ... there isn't any "magic" I can turn
on with Psycopg, right?

Thanks,
Tobias


psycopg by date:

Previous
From: Daniele Varrazzo
Date:
Subject: Re: Problem with Zope 2.13.15, python 2.6.6 psycopg2-2.4.5, pg 9.0.3
Next
From: Daniele Varrazzo
Date:
Subject: Re: JSON type caster