In [1]:
# loads the SQL magic extensions
%load_ext sql
In [2]:
# Connect to Oracle
%sql oracle+cx_oracle://scott:tiger@dbserver:1521/?service_name=orcl.mydomain.com
Out[2]:
In [3]:
%%sql
select * from emp
Out[3]:
In [4]:
Employee_name="SCOTT"
%sql select * from emp where ename=:Employee_name
Out[4]:
In [5]:
%sql update emp set sal=3500 where ename=:Employee_name
%sql commit
%sql select * from emp where ename=:Employee_name
Out[5]:
In [6]:
myResultSet=%sql select ename "Employee Name", sal "Salary" from emp
%matplotlib inline
import matplotlib
matplotlib.style.use('ggplot')
myResultSet.bar()
Out[6]:
In [7]:
%%sql
select e1.ename "Employee Name", e1.job "Job", e2.ename "Manager Name"
from emp e1, emp e2
where e1.mgr = e2.empno(+)
Out[7]:
In [8]:
# save result set into my_ResultSet and copy it to pandas in my_DataFrame
my_ResultSet = _
my_DataFrame=my_ResultSet.DataFrame()
my_DataFrame.head()
Out[8]:
In [ ]: