Prelimcode
Prelimcode
def createconsumer():
import mysql.connector as m
mysql= m.connect(host="localhost", user="root",passwd="Vrushant14"
,database="consumer")
if mysql.is_connected():
print("Connected")
mycursor=mysql.cursor()
#The name of the database is consumer
consumerinfo=[(con_no,name,areacode,address,mobno,
email)]
mycursor.executemany(sqlform, consumerinfo)
mysql.commit()
sleep(2.6)
print("\n\nData stored Successfully!")
home()
def meterreadings():
pread=float(input("Enter the previous reading: "))
cread=float(input("Enter the current readings: "))
units=cread-pread
billamt=int(input("Enter amount: "))
date=input("Enter date in dd/mm/yyyy format: ")
meter=[(con_no,pread,cread,units,billamt,
date)]
mycursor.executemany(sqlform, meter)
mysql.commit()
def viewconsumer():
import mysql.connector as m
mysql= m.connect(host="localhost", user="root",passwd="Vrushant14"
,database="consumer")
if mysql.is_connected():
print("Connected")
mycursor=mysql.cursor()
sleep(1)
home()
def editconsumer():
import mysql.connector as m
mysql= m.connect(host="localhost", user="root",passwd="Vrushant14"
,database="consumer")
if mysql.is_connected():
print("Connected")
mycursor=mysql.cursor()
con=input("Enter your consumer number: ")
print("What do you wish to edit?: ")
print("1. areacode\n2. address\n3. mobile number\n4. Email\
\n5. Go back to home")
c=int(input("Enter your choice: "))
if c==1:
new=input("Enter new area code: ")
sql="Update consumerinfo set areacode="+new+" where ConsumerNo="+con
mycursor.execute(sql)
mysql.commit()
if c==2:
new=input("Enter new address: ")
sql="Update consumerinfo set address="+new+" where ConsumerNo="+con
mycursor.execute(sql)
mysql.commit()
if c==3:
new=input("Enter new mobile number: ")
sql="Update consumerinfo set mobno="+new+" where ConsumerNo="+con
mycursor.execute(sql)
mysql.commit()
if c==4:
new=input("Enter new email: ")
sql="Update consumerinfo set email="+new+" where ConsumerNo="+con
mycursor.execute(sql)
mysql.commit()
if c==5:
home()
def home():
print("\n\t\t\tELECTRICITY BILLING SYSTEM")
print("\nWhat do you wish to do?:")
print("1. Create Consumer\n2. View Consumer Details\n3. Edit Consumer Details\
n4. Billing Details\n5. Exit")
home()