Downloaded 19 times


![PostgreSQL speaks Python! CREATE FUNCTION greet(name TEXT) RETURNS TEXT AS $$ import random attr = random.choice([ 'great', 'fabulous', 'bright', 'brave']) return 'Hello {} {}!'.format(attr, name) $$ LANGUAGE plpythonu; SELECT greet('Python fan');](https://image.slidesharecdn.com/europython2014-lightningtalk-postgresql-python-150529143502-lva1-app6892/75/PostgreSQL-and-Python-Lightning-Talk-EuroPython2014-3-2048.jpg)





PL/Python allows users to write PostgreSQL functions and procedures using Python. It enables accessing PostgreSQL data and running Python code from within SQL queries. For example, a function could query a database table, process the results in Python by accessing modules, and return a value to the SQL query. This opens up possibilities to leverage Python's extensive libraries and expressiveness to expose data and perform complex validation from PostgreSQL.