/sqlmagic

SQL cell magic for IPython

Primary LanguagePython

SQL Magic for IPython

Author: Aiyesha Ma & Marcos Sainz
Tested on IPython Version 0.13.1

This SQL cell magic allows you to open multiple connections to several databases and then reference the connections by name inside IPython.

Adapted from:

Load using:

import sqlmagic
reload(sqlmagic) # useful if you plan to be modifying this file

Now you can do the following line magic to setup a connection:

%connect {"name": "connection_name", "params": {"host": "host", "db": "database_name", "user": "user", "password": "password"}}

And then reference and use the connection via cell magic:

%%sql connection_name
select * from foo