From the course: Advanced SQL for Data Scientists

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

PL/Python functions

PL/Python functions

From the course: Advanced SQL for Data Scientists

Start my 1-month free trial

PL/Python functions

- [Instructor] Now, it is possible to write user-defined functions in Python when using Postgres. And we write Python by using the PL/Python language. So the PL/Python language is a Postgres extension. And as I mentioned, it makes it possible to write SQL functions in Python. And what we would do is basically call the create extension command. And in this case, we could call the create extension command and then specify plpythonu and then either version two or version three. Now, let's look at some pros and cons. Now, there are definitely reasons to use Python. For many people who work in data science, we already know Python. It's a well-developed language. We have a lot of tools in it. We have ecosystems for developing around Python. We can also reuse code we've already written. We might be able to just copy and paste some stuff into our user deploying functions. And one of the other nice things is if we have to…

Contents