#coding:utf-8
import cx_Oracle
conn=cx_Oracle.connect('username/passwod@IP:1521/myorcl')
lookfor_ip='''select * from ip_scan
order by to_number(substr(ip_add, instr(ip_add, '.', 1, 1) + 1, instr(ip_add, '.', 1, 2) - instr(ip_add, '.', 1, 1))),
to_number(substr(ip_add, instr(ip_add, '.', 1, 2) + 1, instr(ip_add, '.', 1, 3) - instr(ip_add, '.', 1, 2))),
to_number(substr(ip_add, instr(ip_add, '.', 1, 3) + 1))'''
x=conn.cursor().execute(lookfor_ip)
counts=0
for l in x:
print l
if counts>20:
break
counts+=1
conn.close()