Bringing native psql magic into Jupyter Notebook

How to get native psql productivity into Jupyter Notebook environment

PSQL JUPYTER NOTEBOOK

Jupyter Notebook is for Python users

Jupyter Notebook is a web-based interactive environment for creating and sharing documents that contain live code, equations, visualizations, and narrative text. It’s an incredibly powerful tool for interactively developing and presenting data science projects, helps streamline work from codes to full-blown reports and enables more productivity and easy collaboration.

For those who use SQL for their data projects, Jupyter Notebook allows few different ways to connect to JDBC/ODBC data sources and manipulate data — my personal favourite is ipython-sql which introduces %sql (or %%sql) magic into Jupyter Notebook. 

Jupyter Notebook is also for PostgreSQL users

The primary front-end for PostgreSQL users is the psql command-line program, which can be used to enter SQL queries directly or execute them from a file. In addition, psql provides a number of meta-commands and various shell-like features to facilitate writing scripts and automating a wide variety of tasks. 

Jupyter Notebook %sql and %%sql magic arrive with some PostgreSQL feature packaged, including psql-style "backslash" meta-commands (\d, \dt, etc.) but it does not cover the complete list of available meta-commands.

Learn how to run native psql commands within the Jupyter Notebook

Learn how to run native psql commands, including all psql meta-commands and options, within the Jupyter Notebook and capture the output back to the environment. 

Check my Medium article Bringing native psql magic into Jupyter Notebook - How to get native psql productivity into Jupyter Notebook environment.


bringing native psql magic into Jupyter Notebook

Up to this day (February 2021) Bringing native psql magic into Jupyter Notebook is the most popular article I've published on Medium. With both Jupyter Notebook and PostgreSQL becoming more popular every year, it's easy to see why users just want to do more with both and not switch between them.

...

Subscribe to the newsletter

Subscribe for email updates, new blog posts and videos published.