0% found this document useful (0 votes)
2 views7 pages

UPSC Registration System Code

The document contains a Python script for a UPSC Registration System that connects to a MySQL database. It creates a database and two tables for registration and login information, allowing users to register and view their details. The script includes user input handling for registration and login processes, as well as options to add or view registration details.

Uploaded by

saanvisingh237
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)
2 views7 pages

UPSC Registration System Code

The document contains a Python script for a UPSC Registration System that connects to a MySQL database. It creates a database and two tables for registration and login information, allowing users to register and view their details. The script includes user input handling for registration and login processes, as well as options to add or view registration details.

Uploaded by

saanvisingh237
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

SOURCE CODE

# UPSC Registration System

import [Link] as sql


conn = [Link](host="localhost", user="root",
password="mysql@2025@root")
cur = [Link]()
print('connected successfully to database')

# ---------- Step 2: Create database if it doesn't exist ----------


[Link]("CREATE DATABASE IF NOT EXISTS UPSC")
[Link]()
print("Database 'UPSC' is ready.")

[Link]()
conn = [Link](host="localhost", user="root",
password="mysql@2025@root", database="UPSC")
cur = [Link]()

if conn.is_connected():
print("Connected successfully to database UPSC")

# Registration table
[Link]("""
CREATE TABLE IF NOT EXISTS registration_information(
reg_no INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(20),
father_name VARCHAR(15),
mother_name VARCHAR(15),
examination_applied VARCHAR(40),
year INT(4),
gender VARCHAR(11),
date_of_birth VARCHAR(10),
nationality VARCHAR(15),
marital_status VARCHAR(10),
community VARCHAR(15),
minority VARCHAR(4),
add1 VARCHAR(40),
add2 VARCHAR(40),
add3 VARCHAR(40),
dist VARCHAR(20),
state VARCHAR(20),
pin_code INT(6),
pho_no BIGINT,
mobile_no BIGINT,
e_mail VARCHAR(45),
education_qualification VARCHAR(100),
preference VARCHAR(10),
p_f_cds_pabt VARCHAR(5),
sainik_milt_sch VARCHAR(5),
son_sainik_milt_sch VARCHAR(5),
aadhar_no BIGINT
)
""")

# Login table
[Link]("""
CREATE TABLE IF NOT EXISTS login_info(
user VARCHAR(10) PRIMARY KEY,
pass VARCHAR(10)
)
""")

[Link]()

# ---------- Step 5: Login / Registration ----------


print("\n--- UPSC LOGIN ---")

cur .execute ("SELECT * FROM login_info")


data = [Link]()

user=input('enter user name')


passwd=input('enter the password')

if (user, passwd) in data:


print("$$$$$$$$$$$$$$$$ UPSC REGISTRATION
$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
print("1: ADD DETAILS")
print("2: VIEW DETAILS")
print("3: QUIT")
ch = int(input("Enter your choice: "))

# ---------- ADD DETAILS ----------


if ch == 1:
v_ea = input("Enter the examination applied: ")
v_yr = input("Enter the year: ")
v_name = input("Enter your name: ")
v_gen = input("Enter your gender: ")
v_dob = input("Enter your date of birth (dd-mm-yyyy): ")
v_f_na = input("Enter your father’s name: ")
v_m_na = input("Enter your mother’s name: ")
v_nat = input("Enter your nationality: ")
v_mar_st = input("Enter your marital status: ")
v_comm = input("Enter your community: ")
v_min = input("Do you belong to minority (Yes/No): ")
v_add1 = input("Enter address line 1: ")
v_add2 = input("Enter address line 2: ")
v_add3 = input("Enter address line 3: ")
v_dist = input("Enter your district: ")
v_state = input("Enter your state: ")
v_pin = input("Enter your pin code: ")
v_pho = input("Enter your phone number: ")
v_mob = input("Enter your mobile number: ")
v_ema = input("Enter your mail ID: ")
v_edu = input("Enter your education qualification: ")
v_aadh = input("Enter your Aadhar number: ")
v_pre = input("Enter your preference: ")
v_p_f = input("Did you ever fail in PABT (Yes/No): ")
v_stu_sa = input("Are you a student of Lucknow Public School (Yes/No): ")
v_son_mil = input("Are you son of a military officer (Yes/No): ")

v_sql = ("INSERT INTO registration_information("

"name,father_name,mother_name,examination_applied,year,gender,"
"date_of_birth,nationality,marital_status,community,minority,"
"add1,add2,add3,dist,state,pin_code,pho_no,mobile_no,e_mail,"
"education_qualification,preference,p_f_cds_pabt,sainik_milt_sch,"
"son_sainik_milt_sch,aadhar_no) "
"VALUES
(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,"
"%s,%s,%s,%s,%s,%s,%s)")

[Link](v_sql, (v_name, v_f_na, v_m_na, v_ea, v_yr, v_gen, v_dob,


v_nat,
v_mar_st, v_comm, v_min, v_add1, v_add2, v_add3, v_dist,
v_state, v_pin, v_pho, v_mob, v_ema, v_edu, v_pre, v_p_f,
v_stu_sa, v_son_mil, v_aadh))
[Link]()
print("\nRegistered successfully!")
# ---------- VIEW DETAILS ----------
elif ch == 2:
reg = int(input("Enter your registration number: "))
[Link]("SELECT * FROM registration_information WHERE reg_no=%s",
(reg,))
data = [Link]()
if data:
print("\n--- REGISTRATION DETAILS ---")
print("Name:", data[1])
print("Father Name:", data[2])
print("Mother Name:", data[3])
print("Exam Applied:", data[4])
print("Year:", data[5])
print("Gender:", data[6])
print("DOB:", data[7])
print("Nationality:", data[8])
print("Email:", data[20])
print("Mobile:", data[19])
print("Aadhar No:", data[26])
else:
print("No record found!")

elif ch == 3:
print("Exiting... Thank you!")

else:
print("Invalid choice. Please try again.")
else:
print("Invalid username or password!")

[Link]()

You might also like