0% found this document useful (0 votes)
61 views3 pages

1connectivity With Mysql in Python

This document contains code for a telephone billing system in Python. It establishes a connection to a MySQL database called "telephone_billing" and defines functions for checking the database connection, connecting to MySQL, and displaying a menu with options for adding, modifying, searching, and removing inventory items, listing bills, and generating customer bills.

Uploaded by

hemant singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views3 pages

1connectivity With Mysql in Python

This document contains code for a telephone billing system in Python. It establishes a connection to a MySQL database called "telephone_billing" and defines functions for checking the database connection, connecting to MySQL, and displaying a menu with options for adding, modifying, searching, and removing inventory items, listing bills, and generating customer bills.

Uploaded by

hemant singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

###################################################################################

#############

#***************ARMY PUBLIC SCHOOL S.P. MARG LUCKNOW


******************************************

#***************WELCOME TO TELEPHONE BILLING


SYSTEM*********************************************

#***************DESIGNEG AND MAINTAINED BY:


#*************** HEMANT SINGH
#*************** CLASS XII B
#*************** ROLL NO - [2020-2021]

###################################################################################
###########

import mysql.connector

# GLOBAL VARIABLES DECLERATION

myConnection=""
cursor=""
userName=input("ENTER MYSQL SERVER'S USERNAME :")
password=input("ENTER MYSQL SERVER'S PASSWORD :")
code="utf8"

#MODULE TO CHECK MY SQL CONNECTIVITY


def MY_SQL_connection_check():

global myConnection
global userName
global password

myConnection=mysql.connector.connect(host="localhost",user=userName
,passwd=password ,charset='utf8')
if myConnection:
print(" CONGRATULATIONS ! YOUR MYSQL CONNECTION HAS BEEN ESTABLISHED ! ")
cursor=myConnection.cursor()

cursor.execute("CREATE DATABASE IF NOT EXISTS TELEPHONE_BILLING")


cursor.execute("COMMIT")
cursor.close()
return myConnection
else:
print(" ERROR ESTABLISHING MYSQL CONNECTION CHECK USERNAME AND PASSWORD !")

#MODULE TO ESTABLISH MYSQL CONNECTION


def MYSQLconnection():

global userName
global password
global myConnection
global cid
global pcode
myConnection=mysql.connector.connect(host="localhost",user=userName,passwd=password
, database="telephone_billing" , auth_plugin='mysql_native_password',charset=code )
if myConnection:
return myConnection
else:
print("ERROR ESTABLISHING MYSQL CONNECTION ! ")
myConnection.close()

myConnection = MY_SQL_connection_check()

if myConnection:

MYSQLconnection ()
while(True):

print("""
1 >FOR NEW ITEM

2 >FOR WOMEN SECTION


3 >FOR MEN SECTION
4 >FOR KID SECTION
5 >FOR MODIFY ITEM
6 >FOR SEARCH ITEM
7 >FOR SHOW ALL INVENTORY ITEM WISE
8 >FOR REMOVE ITEM
9 >LIST ALL BILLS
10 >GENERATE CUSTOMER BILL
11 >EXIT
""")
break

'''
choice = int(input("Please Enter Your Choice : "))
if choice == 1:
addItem()

elif choice ==2:


womenSection()
elif choice ==3:
menSection()
elif choice ==4:
kidsSection()
elif choice ==5:
modifyItem()
elif choice ==6:
item=searchItem()
if item:
print("*******Record Found !!!*******")
else:
print("Record Not Found , Please Try Again !")
elif choice ==7:
showInventory()
elif choice ==8:
removeItem()
elif choice ==9:
allBills()
elif choice == 10:
generateBill()
elif choice == 11:

'''

You might also like