0% found this document useful (0 votes)
13 views6 pages

7 Sports Club

The document contains a Python code for managing a sports club database using MySQL. It includes functions for registering club members, viewing member details based on various criteria, searching for fee details, and removing members from the database. The code also features a menu-driven interface for user interaction.

Uploaded by

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

7 Sports Club

The document contains a Python code for managing a sports club database using MySQL. It includes functions for registering club members, viewing member details based on various criteria, searching for fee details, and removing members from the database. The code also features a menu-driven interface for user interaction.

Uploaded by

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

SOURCE

CODE
DBMS: MySQL
Host : localhost
User: root
Pass: ip
DataBase: sports
Table name -club
Table Structure: (Images Bellow)
PYTHON CODE
import os
import platform
import mysql.connector
import pandas as pd

mydb=mysql.connector.connect(host="localhost",\
user="root",\
passwd="ip",\
database="sports"
)
mycursor=mydb.cursor()

def RegisterClub():
L=[]
enroll=int(input("Enter the registration number(Max 5 Digits) : "))
L.append(enroll)
sname=input("Enter the Name of club member: ")
L.append(sname)
age=int(input("Enter Age of member : "))
L.append(age)
city=input("Enter the City of the member : ")
L.append(city)
sportname=input("Enter the sport name : ")
L.append(sportname)
phone=input("Enter Phone number in Digits : ")
L.append(phone)
address=input("Enter Address of member : ")
L.append(address)
regfee=int(input("Enter the registration Fee : "))
L.append(regfee)
value=L
sql="insert into club (enroll,sname,age,city,class,phone,address,regfee)
values (%s,%s,%s,%s,%s,%s,%s,%s)"
mycursor.execute(sql,value)
mydb.commit()

def ClubView():
print("Select the search criteria : ")
print("1. Enroll")
print("2. Name")
print("3. Age")
print("4. City")
print("5. phone")
print("6. Address")
print("7. All")
ch=int(input("Enter the choice : "))
if ch==1:
s=int(input("Enter enroll no : "))
rl=(s,)
sql="select * from club where enroll=%s"
mycursor.execute(sql,rl)
elif ch==2:
s=input("Enter Name : ")
rl=(s,)
sql="select * from club where sname=%s"
mycursor.execute(sql,rl)
elif ch==3:
s=int(input("Enter age : "))
rl=(s,)
sql="select * from club where age=%s"
mycursor.execute(sql,rl)
elif ch==4:
s=input("Enter City : ")
rl=(s,)
sql="select * from club where City=%s"
mycursor.execute(sql,rl)
elif ch==5:
s=input("Enter phone : ")
rl=(s,)
sql="select * from club where phone=%s"
mycursor.execute(sql,rl)
elif ch==6:
s=input("Enter address : ")
rl=(s,)
sql="select * from club where address=%s"
mycursor.execute(sql,rl)
elif ch==7:
sql="select * from club"
mycursor.execute(sql)
res=mycursor.fetchall()

print("The Memebers details are as follows : ")


print("(ROll, Name, Age, Class, City)")
for x in res:
print(x)

def SearchClub():
print("Please enter the details to view the fee details :")
enroll=int(input("Enter the enroll number of the member whose fee is to be
viewed : "))
sql="Select * from club where enroll=%s"
rl=(enroll,)
mycursor.execute(sql,rl)
res=mycursor.fetchall()
if res==None:
print("Record not Found . . . ")
return
print("The details of the memebrs are : " )
for x in res:
print(x)

def RemoveClub():
enroll=int(input("Enter the enroll number of the memeber to be
deleted : "))
rl=(enroll,)
sql="Delete from club where enroll=%s"
mycursor.execute(sql,rl)
mydb.commit()

def MenuSet(): #Function For The Memeber Management System


print("Enter 1 : To Register Club")
print("Enter 2 : To View Club ")
print("Enter 3 : To Search Club ")
print("Enter 4 : To Remove Club")
# try: #Using Exceptions For Validation

userInput = int(input("Please Select An Above Option: ")) #Will Take Input From
User except ValueError:
# exit("\nHy! That's Not A Number") #Error Message

# finally:
print("\n") #Print New Line
if(userInput == 1):
RegisterClub()
elif (userInput==2):
ClubView()
elif (userInput==3):
SearchClub()
elif (userInput==4):
RemoveClub()
else:
print("Enter correct choice. . . ")

def runAgain():
runAgn = input("\nwant To Run Again Y/n: ")
while(runAgn.lower() == 'y'):
if(platform.system() == "Windows"):
print(os.system('cls'))
else:
print(os.system('clear'))
MenuSet()

MenuSet()
runAgain()

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy