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
- [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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Extending SQL with user-defined functions3m 6s
-
(Locked)
SQL query functions8m 40s
-
(Locked)
Function overloading5m 41s
-
(Locked)
Function volatility4m 2s
-
(Locked)
PL/Python functions3m 44s
-
(Locked)
Challenge: Write a user-defined function34s
-
(Locked)
Solution: Write a user-defined function1m 35s
-
(Locked)
-
-