From: | Tobias Oberstein <tobias(dot)oberstein(at)gmail(dot)com> |
---|---|
To: | Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com> |
Cc: | psycopg(at)postgresql(dot)org |
Subject: | Re: JSON type caster |
Date: | 2012-09-18 15:57:35 |
Message-ID: | 505899EF.3010909@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Daniele Varrazzo | 2012-09-18 16:44:09 | Re: JSON type caster |
Previous Message | Daniele Varrazzo | 2012-09-18 12:08:52 | Re: Problem with Zope 2.13.15, python 2.6.6 psycopg2-2.4.5, pg 9.0.3 |