Re: JSON type caster
От | Tobias Oberstein |
---|---|
Тема | Re: JSON type caster |
Дата | |
Msg-id | 505899EF.3010909@gmail.com обсуждение исходный текст |
Ответ на | Re: JSON type caster (Daniele Varrazzo <daniele.varrazzo@gmail.com>) |
Ответы |
Re: JSON type caster
|
Список | 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 по дате отправления: