import mysql
import mysql
connector
import pyfiglet
import re
class IRCTCSystem:
def __init__(self):
try:
self.conn = mysql.connector.connect(
host='localhost',
user='root',
password='utkarsh',
database='irctc'
self.cursor = self.conn.cursor(buffered=True)
self.conn.autocommit = True
exit(1)
def display_header(self):
print('+---------------------------------------------------------------------------------------------------------------------------------
---+')
print('\
t+---------------------------------------------------------------------------------------------------------------------------------+')
print(pyfiglet.figlet_format("I R C T C"))
print(pyfiglet.figlet_format('PORTAL'))
print(pyfiglet.figlet_format('20252-26'))
print('\
t+---------------------------------------------------------------------------------------------------------------------------------+')
print('+---------------------------------------------------------------------------------------------------------------------------------
---+')
try:
query = "SELECT user_name FROM user_accounts WHERE user_name = %s AND password = %s"
data = self.cursor.fetchone()
print("+---------------------------------------------------------+")
print('\t+------------------------------------------------------+')
print('\t+------------------------------------------------------+')
print('+---------------------------------------------------------+')
return True
else:
return False
try:
if not self.validate_phone(phone):
return False
if not self.validate_password(password):
return False
if password != confirm_password:
return False
return False
try:
except ValueError:
return False
query = """
"""
dob.strftime('%Y-%m-%d'), age)
self.cursor.execute(query, values)
print('+------------------------------------------------------------------------------------------+')
print('+------------------------------------------------------------------------------------------+')
return True
return False
except Exception as e:
return False
try:
if not self.validate_phone(phone):
return False
return False
try:
except ValueError:
return False
query = """
"""
to_station, journey_date.strftime('%Y-%m-%d'))
self.cursor.execute(query, values)
print('+------------------------------------------------------------------------------------------+')
print('+------------------------------------------------------------------------------------------+')
return True
except Exception as e:
return False
try:
if not self.validate_phone(phone):
return False
self.cursor.execute(query, (phone,))
data = self.cursor.fetchone()
if data:
print(f"{header}: {value}")
return True
else:
return False
def main_menu(self):
while True:
print('''
+----------------------------------------------------------------+
| 1. TICKET BOOKING |
| 2. TICKET CHECKING |
| 3. TICKET CANCELLING |
| 4. ACCOUNT DETAILS |
| 5. VIEW BOOKINGS |
| 6. LOGOUT |
+-----------------------------------------------------------------+
''')
try:
if choice == 1:
self.ticket_booking()
elif choice == 2:
self.ticket_checking()
elif choice == 3:
elif choice == 4:
elif choice == 5:
self.view_bookings()
elif choice == 6:
print('THANK YOU FOR USING IRCTC!')
break
else:
except ValueError:
def view_bookings(self):
try:
self.cursor.execute(query)
bookings = self.cursor.fetchall()
if not bookings:
return
print("\nBooking Details:")
print("+----------------------------------------------------------------+")
print("+----------------------------------------------------------------+")
def main():
irctc = IRCTCSystem()
irctc.display_header()
while True:
print('''
+====================================================================================
=======================+
| 3. See details |
| 5. EXIT! |
+====================================================================================
=======================+
''')
try:
if choice == 1:
if irctc.signup():
irctc.main_menu()
elif choice == 2:
if irctc.signin():
irctc.main_menu()
elif choice == 3:
elif choice == 4:
elif choice == 5:
print('''
+-------------------------------------------+
THANK YOU
+-------------------------------------------+
''')
break
else:
except ValueError:
if __name__ == "__main__":
main()