Python integration in Postgresql

DevconTLV February Conference, Thursday, February 14, 2013, 15:10

One of the exciting features of the Postgresql open source database engine is the ability to write stored procedures or functions in Python. Integrating python code directly into the database gives the database engine unprecedented power. For example, a function can check the server's file system to see if a file exists. This can be done on a database trigger, when a field containing a file name is added or updated, it can give the user an error if the file doesn't exist. A delete trigger can call python code to check references and delete a file from the file system if it is no longer needed. Other examples include: sending emails, FTPing files, processing data in a simpler manner then is possible using extended SQL syntax typically used in database functions.

 

There are tremendous advantages in writing database functions directly in Python. The ability increases the power of the database so that it is not tied down to strictly data access. In certain circumstances, it can be used as an application server, by putting your business logic inside database functions. This has to be managed correctly so that MVC principles are adhered to.

Sim Zacks is the CIO at CompuLab, in Yokneam. He started developing in Python v1.4 in 1996 in a Comparative Programming Language course. Since then, Sim has worked in various software development and database positions.

His current project is building a cross-platform ERP system using the WX Python framework, django and postgresql. Sim made aliyah from the US in 2003.

Other Presentations at DevconTLV February

Open Accessibilty Menu