Re: pl/python composite type array as input parameter

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: pl/python composite type array as input parameter
Дата
Msg-id 556CFC6F.90805@aklaver.com
обсуждение исходный текст
Ответ на Re: pl/python composite type array as input parameter  (Filipe Pina <filipe.pina@impactzero.pt>)
Ответы Re: pl/python composite type array as input parameter  (Rémi Cura <remi.cura@gmail.com>)
Re: pl/python composite type array as input parameter  (Filipe Pina <filipe.pina@impactzero.pt>)
Список pgsql-general
On 06/01/2015 07:42 AM, Filipe Pina wrote:
> Thanks for the reply anyway, it's a pity though, it'd be useful..
>
> Another bump I've found along the pl/python road: insert ROWTYPE in table..
> Maybe you have some hint on that? :)
>
> So, in PLPGSQL I can:
>
> DECLARE
>    my_var my_table;
> BEGIN
>    my_var.col1 := 'asd';
>    INSERT INTO my_table VALUES(my_table.*);
> END;
>
> How would I do something like that in pl/python?
>
> First, how to declare a ROW-TYPE variable, as they're all python mappings?
>
> my_var = { 'col1': 'asd' } enough? it'd would miss all the other columns...
>
> Second, how to insert it?
>
> plpy.prepare and .execute say they don't support composite types, so I
> cannot simply pass
>
> pl = plpy.prepare('INSERT INTO core_customer VALUES ($1)', ['my_table'])
>
> Any workarounds for this? (meaning I wouldn't have to specify any
> columns in the insert statement)

http://www.postgresql.org/docs/9.4/interactive/sql-insert.html

pl = plpy.prepare('INSERT INTO core_table SELECT * FROM my_table')

>
> Thanks
>
> On Sex, Mai 29, 2015 at 2:00 , Peter Eisentraut <peter_e@gmx.net> wrote:
>> On 5/18/15 10:52 AM, Filipe Pina wrote:
>>
>>     But one of the functions I need to create needs to accept an array
>>     of records.
>>
>> PL/Python doesn't support that. Some more code needs to be written to
>> support that. You did everything correctly. I don't know of a good
>> workaround.


--
Adrian Klaver
adrian.klaver@aklaver.com


В списке pgsql-general по дате отправления:

Предыдущее
От: John R Pierce
Дата:
Сообщение: Re: odbc to emulate mysql for end programs
Следующее
От: Arthur Silva
Дата:
Сообщение: Re: advocating LTS release and feature-train release cycles