Thursday, 24 October 2019

GET ORACLE Output in GUI with Buttons. PYTHON

GET ORACLE Output in GUI. PYTHON ## INCOMPLETE ##

NEED TO HAVE :
Python 3.7
cx_Oracle
tkinter
tabulate

To get : [ in cmd/bash : pip install tkinter ]

from tkinter import *
from tkinter import messagebox
import cx_Oracle
from tabulate import tabulate

#con = cx_Oracle.connect('hsdba/banana12@localhost/orcl')
con = cx_Oracle.connect('hsdba/banana12@158.233.307.111/devdb2st')
cur = con.cursor()
cur.execute ("""SELECT B.TABLESPACE_NAME,B.OWNER SCHEMA_NAME,ROUND(SUM(B.BYTES/1024/1024),2) \n
USED_SPACE_MB,A.CREATED,A.LAST_LOGIN FROM DBA_USERS A,DBA_SEGMENTS B WHERE A.USERNAME=B.OWNER GROUP BY \n
B.OWNER,A.CREATED,B.TABLESPACE_NAME,A.LAST_LOGIN ORDER BY B.TABLESPACE_NAME,ROUND(SUM(B.BYTES/1024/1024),2) DESC""")
res = cur.fetchall ()
cur1 = con.cursor()
cur1.execute("select * from v$datafile")
res1 = cur1.fetchall ()
cur2 = con.cursor()
cur2.execute("select * from dba_data_files")
res2 = cur2.fetchmany(16000)
top=Tk()
def clickhere():
        messagebox.showinfo("Click Here",con.version)
button=Button(top,text="Database Version",command=clickhere)
button.place(x=70,y=70)
def checkitout1():
        messagebox.showinfo("Whassup!!",tabulate(res,tablefmt="github"))
button1=Button(top,text="Tablespace Details",command=checkitout1)
button1.place(x=70,y=120)
def checkitout2():
        messagebox.showinfo("Whassup!!",tabulate(res1,tablefmt="fancy_grid"))
button1=Button(top,text="Employees",command=checkitout2)
button1.place(x=70,y=170)
def checkitout3():
        messagebox.showinfo("Whassup!!",tabulate(res2,tablefmt="fancy_grid"))
button1=Button(top,text="Countries",command=checkitout3)
button1.place(x=70,y=220)






4 comments: