[postgis-users] Has anyone got novel Python function example

Regina Obe lr at pcorp.us
Sat Dec 3 21:31:34 PST 2022


Just a side note because a lot of people seem to be deploying on Database as a Service platforms.

The big DbaaS providers do not offer plpython as an extension because it is untrusted. You probably won’t find any PL language that is untrusted on any of the top 4 cloud providers.

So if you are using Amazon RDS, Aurora, Microsoft Azure, or Google Cloud DbaaS, you should expect to not have it.

 

Note I’m not talking about running your own VMS  on these, if you have PostgreSQL installed on your own VM, then the DbaaS restrictions don’t affect you. 

 

From: postgis-users [mailto:postgis-users-bounces at lists.osgeo.org] On Behalf Of Imre Samu
Sent: Saturday, December 3, 2022 11:10 PM
To: PostGIS Users Discussion <postgis-users at lists.osgeo.org>
Subject: Re: [postgis-users] Has anyone got novel Python function example

 

> It will be interesting to see novel Python functions in PostGIS.

 

Server side?

 

1. Postgis Raster  see

  "11.3.4. Use PLPython to dump out images via SQL"  

  https://postgis.net/docs/using_raster_dataman.html

 

2.) book:   "PostGIS-Cookbook"  https://www.packtpub.com/product/postgis-cookbook-second-edition/9781788299329

 - "Writing PostGIS functions with PL/Python"

     https://github.com/PacktPublishing/PostGIS-Cookbook-Second-Edition/blob/master/Chapter08/code%20snippets/chp08_R4.sql

 -  "Geocoding with geopy and PL/Python" 

      https://github.com/PacktPublishing/PostGIS-Cookbook-Second-Edition/blob/master/Chapter08/code%20snippets/chp08_R7.sql

 

3.) The plpygis has some simple examples: https://plpygis.readthedocs.io/en/latest/examples.html

"plpygis is a Python conveter to and from the PostGIS geometry type, WKB, EWKB, GeoJSON and Shapely geometries and additionally supports __geo_interface__. plpygis is intended for use in PL/Python functions."

see more: 

-  https://plpygis.readthedocs.io/en/latest/

-  https://github.com/bosth/plpygis

-  slide ( 2017 )  https://2017.foss4g.org/post_conference/Extending-PostGIS-with-Python.pdf

 

4.)  CartoDB is also plpythonu based.

- https://github.com/search?q=repo%3ACartoDB%2Fcartodb+plpython <https://github.com/search?q=repo%3ACartoDB%2Fcartodb+plpython&type=code> &type=code

- crankshaft ( CARTO Spatial Analysis extension for PostgreSQL )  https://github.com/CartoDB/crankshaft

 

5.)  (tutorial) Map Matching in PostGIS with Valhalla and PL/Python

https://gis-ops.com/map-matching-postgis-plpython/

 

6.) Apache MADlib ( Graph, Deep learning, Statistics,  .. ) 

https://madlib.apache.org/docs/latest/index.html   ( mostly plpythonu based ) 

 

....

 

Be careful:

"PL/Python is only available as an “untrusted” language, meaning it does not offer any way of restricting what users can do in it and is therefore named plpython3u. A trusted variant plpython might become available in the future if a secure execution mechanism is developed in Python. The writer of a function in untrusted PL/Python must take care that the function cannot be used to do anything unwanted, since it will be able to do anything that could be done by a user logged in as the database administrator. Only superusers can create functions in untrusted languages such as plpython3u."

https://www.postgresql.org/docs/15/plpython.html

https://dba.stackexchange.com/questions/132352/why-is-pl-python-untrusted

 

 

Regards,

 Imre

 

 

Shaozhong SHI <shishaozhong at gmail.com <mailto:shishaozhong at gmail.com> > ezt írta (időpont: 2022. dec. 3., Szo, 21:59):

It will be interesting to see novel Python functions in PostGIS.

 

Regards,

David

_______________________________________________
postgis-users mailing list
postgis-users at lists.osgeo.org <mailto:postgis-users at lists.osgeo.org> 
https://lists.osgeo.org/mailman/listinfo/postgis-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20221204/714a0b0f/attachment.htm>


More information about the postgis-users mailing list