fork download
  1. #!/usr/bin/python
  2.  
  3.  
  4. import os,sys
  5. from datetime import datetime,timedelta
  6. import cx_Oracle as orcl
  7. import mysql.connector as pymysql
  8. from pprint import pprint
  9.  
  10. alarms = {198087342:'2G'}
  11.  
  12. db=orcl.connect('sys','oracle','minos',mode=orcl.SYSDBA)
  13. cursor =db.cursor()
  14. cursor.execute("select position1,customattr5,to_char(alarmraisedtime_gmt,'YYYY-MM-DD HH24:MI:SS'),code from CAFFM4X.currentalarm where code in ('198087342')")
  15. p=cursor.fetchall()
  16.  
  17. print p
  18.  
  19.  
  20. conn = pymysql.connect(user='omcr',password='omcr',host='117.239.216.50',database='omcr')
  21. mycursor = conn.cursor()
  22.  
  23. for j in p:
  24. values =[j[1][0:17],j[1][0:15],j[0].split('@')[-2],'Zte',alarms[j[3]],datetime.strptime(j[2],'%Y-%m-%d %H:%M:%S')]
  25. #bts_name=j[1].split('_')[-2]
  26. print values
  27. sql=("insert ignore into omcr.currentbtsdown_sectors(sector_name,bts_name,bsc_name,make,tech,down_time) values(%s,%s,%s,%s,%s,%s)")
  28. mycursor.execute(sql,(values))
  29.  
  30.  
  31. cursor.execute("select position1,customattr5,to_char(alarmraisedtime_gmt,'YYYY-MM-DD HH24:MI:SS'),to_char(alarmclearedtime,'YYYY-MM-DD HH24:MI:SS'),code from CAFFM4X.historyalarm \
  32. where code in ('198087342') and alarmclearedtime>sysdate-3/24")
  33.  
  34. outage = cursor.fetchall()
  35.  
  36. for k in outage:
  37. values =[k[1][0:17],k[1][0:15],k[0].split('@')[-2],'Zte',alarms[k[4]],datetime.strptime(k[2],'%Y-%m-%d %H:%M:%S'),datetime.strptime(k[3],'%Y-%m-%d %H:%M:%S')]
  38. #print values
  39. sql = ("replace into omcr.currentbtsdown_sectors(sector_name,bts_name,bsc_name,make,tech,down_time,up_time) values(%s,%s,%s,%s,%s,%s,%s)")
  40. mycursor.execute(sql,(values))
  41.  
  42.  
  43. conn.commit()
  44. conn.close()
  45. # your code goes here
Success #stdin #stdout 0.02s 25876KB
stdin
import os
import platform
import mysql.connector
import datetime
mydb=mysql.connector.connect(host="localhost",user="root",passwd="root",database="hotel",charset="utf8")
mycursor=mydb.cursor()

def registercust():
    L=[]
    custno=int(input('Enter customer no='))
    L.append(custno)
    name=input('Enter name:')
    L.append(name)
    addr=input('Enter address:')
    L.append(addr)
    jr_date=input('Enter date of journey:')
    L.append(jr_date)
    source=input('Enter source:')
    L.append(source)
    destination=input('Enter destination:')
    L.append(destination)
    
    cust=(L)
    sql='insert into pdata(custno,custname,addr,jrdate,source,destination) values(%s,%s,%s,%s,%s,%s)'
    mycursor.execute(sql,cust)
    mydb.commit()


def ticketprice():
    L=[]
    cno=int(input('Enter custoner no='))
    L.append(cno)
    print('We have the following rooms for you:-')
    print('1. type First class--->rs 6000 PN\-')
    print('2. type Business class--->rs 4000 PN\-')
    print('3. type Economy class--->rs 2000 PN\-')
    x=int(input('Enter your choice:'))
    n=int(input('Enter No. of Passengers:'))
    if x==1:
        print('you have opted First class.')
        s=6000*n
        L.append(s)
    elif x==2:
        print('you have opted Business class.')
        s=4000*n
        L.append(s)
    elif x==3:
        print('you have opted Economy class.')
        s=2000*n
        L.append(s)
    else:
        print('Please select a class type.')
    print('your ticket charge is =',s,'\n')
    print('Extra luggage charge 100 rs per kg')
    
    y=int(input('Enter your weight,of extra luggage:'))
    z=y*100
    L.append(z)
    tkt=(L)
    print('Your Totalbill:',s+z,'\n')
    g_tot=s+z
    L.append(g_tot)
    sql="insert into tkt (custno,tkt_tot,lug_tot,g_tot) values (%s,%s,%s,%s)"
    mycursor.execute(sql,tkt)
    mydb.commit()
    
def dis():
    custno=int(input("Enter the customer number whose bill to be viewed : "))
    sql="Select pdata.custno, pdata.custname, pdata.addr,pdata.source,pdata.destination,tkt.tkt_tot,tkt.lug_tot, g_tot from pdata INNER JOIN tkt ON pdata.custno=tkt.custno and tkt.custno = %s"
    rl=(custno,)
    mycursor.execute(sql,rl)
    res=mycursor.fetchall()
    for x in res:
        print(x)

def dispall():
    
    sql="Select pdata.custno, pdata.custname, pdata.addr,pdata.source,pdata.destination,tkt.tkt_tot,tkt.lug_tot, g_tot from pdata INNER JOIN tkt ON pdata.custno=tkt.custno" 
    mycursor.execute(sql)   
    res=mycursor.fetchall()
    print("The Customer details are as follows : ")
    
    for x in res:
        print(x)
  
def Menuset():
    print('Enter 1: To enter customer data.')
    print('Enter 2: For ticketamount.')
    print('Enter 3: Display customerwise Details.')
    print('Enter 4: Display All Details.')
    print('Enter 5: Exit')
    
    userinput=int(input('Enter your choice:'))
    if userinput==1:
        registercust()
    elif userinput==2:
        ticketprice()
    elif userinput==3:
        dis()
    elif userinput==4:
        dispall()
    elif userinput==5:
        quit()
    else:
        print('Enter correct choice.')

Menuset()
def runagain():
    runagn=input('\nWant to run again? y/n:')
    while runagn=='y':
        if platform.system=='windows':
            print(os.system('cls'))
        else:
            print(os.system('clear'))
        Menuset()
        runagn=input('\nWant to run again? y/n:')
runagain()


 
stdout

import os,sys
from datetime import datetime,timedelta
import cx_Oracle as orcl
import mysql.connector as pymysql
from pprint import pprint

alarms = {198087342:'2G'}

db=orcl.connect('sys','oracle','minos',mode=orcl.SYSDBA)
cursor =db.cursor()
cursor.execute("select position1,customattr5,to_char(alarmraisedtime_gmt,'YYYY-MM-DD HH24:MI:SS'),code from CAFFM4X.currentalarm  where code in ('198087342')")
p=cursor.fetchall()

print p


conn = pymysql.connect(user='omcr',password='omcr',host='117.239.216.50',database='omcr')
mycursor = conn.cursor()

for j in p:
	values =[j[1][0:17],j[1][0:15],j[0].split('@')[-2],'Zte',alarms[j[3]],datetime.strptime(j[2],'%Y-%m-%d %H:%M:%S')]
	#bts_name=j[1].split('_')[-2]
	print values
	sql=("insert ignore into omcr.currentbtsdown_sectors(sector_name,bts_name,bsc_name,make,tech,down_time) values(%s,%s,%s,%s,%s,%s)")
        mycursor.execute(sql,(values))

	
cursor.execute("select position1,customattr5,to_char(alarmraisedtime_gmt,'YYYY-MM-DD HH24:MI:SS'),to_char(alarmclearedtime,'YYYY-MM-DD HH24:MI:SS'),code from CAFFM4X.historyalarm  \
where code in ('198087342') and alarmclearedtime>sysdate-3/24")

outage = cursor.fetchall()

for k in outage:
	values =[k[1][0:17],k[1][0:15],k[0].split('@')[-2],'Zte',alarms[k[4]],datetime.strptime(k[2],'%Y-%m-%d %H:%M:%S'),datetime.strptime(k[3],'%Y-%m-%d %H:%M:%S')]
	#print values
	sql = ("replace into omcr.currentbtsdown_sectors(sector_name,bts_name,bsc_name,make,tech,down_time,up_time) values(%s,%s,%s,%s,%s,%s,%s)")
	mycursor.execute(sql,(values))


conn.commit()
conn.close()
# your code goes here