hstore_plpython3u

hstore_plpython3u

plpython3u : transform between hstore and plpython3u

Overview

ID Extension Package Version Category License Language
3293
hstore_plpython3u
plpython3u
1.0
LANG
PostgreSQL
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
----d-r
No
No
No
Yes
yes
no
Relationships
Requires
hstore
plpython3u
See Also
hstore_pllua
hstore_plluau
hstore_plperl
hstore_plperlu
faker
plpgsql
Siblings
plpython3u
jsonb_plpython3u
ltree_plpython3u

Packages

PG18 PG17 PG16 PG15 PG14
1.0
1.0
1.0
1.0
1.0

This is a built-in contrib extension ship with the PostgreSQL kernel

Install

Create this extension with:

CREATE EXTENSION hstore_plpython3u CASCADE; -- requires hstore, plpython3u

Usage

hstore_plpython3u: Transform between hstore and PL/Python3

Provides a transform for the hstore type for PL/Python3U. When loaded, hstore values are automatically converted to Python dicts and vice versa.

CREATE EXTENSION hstore_plpython3u;

CREATE FUNCTION hstore_to_pairs(val hstore) RETURNS text
LANGUAGE plpython3u TRANSFORM FOR TYPE hstore AS $$
  # val is now a Python dict
  return ', '.join(f'{k}={v}' for k, v in sorted(val.items()))
$$;

CREATE FUNCTION make_hstore(key text, value text) RETURNS hstore
LANGUAGE plpython3u TRANSFORM FOR TYPE hstore AS $$
  return {key: value}
$$;

SELECT hstore_to_pairs('a=>1, b=>2'::hstore);
SELECT make_hstore('color', 'blue');
Last updated on