plpython feature idea: an option to return row results as lists

Поиск
Список
Период
Сортировка
От Derek Arnold
Тема plpython feature idea: an option to return row results as lists
Дата
Msg-id 4C5347E5.9060002@dealerbuilt.com
обсуждение исходный текст
Ответы Re: plpython feature idea: an option to return row results as lists  (Alex Hunsaker <badalex@gmail.com>)
Re: plpython feature idea: an option to return row results as lists  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-general
With result rows in plpython returned as dicts rather than lists, we ran
into issues with a need to preserve the column order in the resultset.
Of course, dicts in python have an arbitrary, non-random order. It's
consistent in the result but does not match the order in the query. Our
use case was a third party to a customer and ourselves who required a
specific order of columns in CSVs sent to them.

Has there ever been any interest in adding a keyword option for
returning row lists rather than dicts? I couldn't find any, so I
experimented a little and came up with the attached patch. I tested this
a little...managed to make it not segfault at the very least. :)  I'm
not even close to a guru so there's probably at least one mistake.

As an example:

test=# do language plpythonu $$
a = plpy.execute("""
     SELECT 1 as a, 2 as b, NULL as c, ARRAY[1,2,3] as d;
     """, return_list=True)
for row in a:
     plpy.notice(repr(row))
$$;
NOTICE:  [1, 2, None, [1, 2, 3]]
CONTEXT:  PL/Python anonymous code block
DO

I didn't test with Python 3/plpython3u.

Вложения

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

Предыдущее
От: Scott Frankel
Дата:
Сообщение: Re: PQescapeStringConn
Следующее
От: Alex Hunsaker
Дата:
Сообщение: Re: plpython feature idea: an option to return row results as lists