python jupyter postgres - ghdrako/doc_snipets GitHub Wiki
postgres kernel
pandas
pip install ipython-sql
pip install sqlalchemy
pip install psycopg2
%load_ext sql
Create engine:
- Using sqlalhemy:
from sqlalchemy import create_engine
# Format
engine = create_engine('dialect+driver://username:password@host:port/database')# Example format
engine = create_engine('postgresql://postgres:password123@localhost/dvdrental')
- To connect ipython-sql to your database, use the following format
# Format
%sql dialect+driver://username:password@host:port/database# Example format
%sql postgresql://postgres:password123@localhost/dvdrental
%sql SELECT first_name, last_name from actor order by
tp write your query on multiple lines use %%s
%%sql SELECT actor_id, first_namefrom actorWHERE first_name = 'Ed'*