PostgreSQL and Jupyter notebook

Franck Pachot
Apr 28 · 4 min read

Anaconda

https://www.anaconda.com/distribution/#download-section

Installation

%windir%\System32\cmd.exe "/K" C:\Users\Franck\Anaconda3\Scripts\activate.bat C:\Users\Franck\Anaconda3

IPython SQL

conda install -y -c conda-forge ipython-sql

PostgreSQL

conda install -y -c conda-forge postgresql
conda install -y -c anaconda psycopg2
conda install -y -c conda-forge pgspecial

Create a database

set PGDATA=C:\Anaconda\pgdata
mkdir %PGDATA%
pg_ctl initdb
pg_ctl start
psql -c "create database DEMO;" postgres

Jupyter Notebook

C:\Users\Franck\Anaconda3\python.exe C:\Users\Franck\Anaconda3\cwp.py C:\Users\Franck\Anaconda3 C:\Users\Franck\Anaconda3\python.exe C:\Users\Franck\Anaconda3\Scripts\jupyter-notebook-script.py "C:\Anaconda/"
jupyter.exe notebook --notebook-dir=C:\Anaconda
%load_ext sql
%sql postgresql://localhost/demo
%sql select version()

GitHub Gist and Medium

https://gist.github.com/FranckPachot/31fd2450506a60ae8698b066e0876de9

Franck Pachot

Written by

https://twitter.com/FranckPachot DBA at CERN, Oracle OCM 12c, Oracle ACE Director, Oak Table member. My 499 posts at dbi-services: http://blog.dbi.pachot.net

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade