-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
86 lines (78 loc) · 3.15 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import mysql.connector
from mysql.connector.cursor import MySQLCursor
#connect to database
mydb = mysql.connector.connect(
host = "localhost",
user ="root",
password= "",
database ="travel"
)
def package_choice():
choice = input(("Do you have a budget for the Travel? (y/n): "))
if choice == 'y' or choice == 'Y':
budget = int(input("Enter your budget (INR): "))
print("Packages in your budget are: \n Package name \t Price \t Package Description")
sql=("SELECT * FROM package_info WHERE package_price < %s")
mycursor.execute(sql,(budget,))
record = mycursor.fetchall()
for x in record:
print(x)
package_choice = input("Enter the name of the package you want: ")
sql1 = ("INSERT INTO package_choice VALUES(%s,%s)")
values1 = (username,package_choice)
mycursor.execute(sql1,values1)
print("Thank you for booking the package:",package_choice, ". We Hope to see you soon!")
elif choice == 'n' or choice == 'N':
print("Available Packages are: ")
mycursor.execute("SELECT * FROM package_info")
record = mycursor.fetchall()
for x in record:
print(x)
package_choice = input("Enter the name of the package you want: ")
sql1 = ("INSERT INTO package_choice VALUES(%s,%s)")
values1 = (username,package_choice)
mycursor.execute(sql1,values1)
print("Thank you for booking the package:",package_choice, ". We Hope to see you soon!")
else:
print('Wrong Choice')
mycursor = mydb.cursor()
print("Welcome to Rocket Travel Agency!")
print("1. Login (already existing user)")
print("2. Register (new user)")
choice = int(input("Select your choice: "))
if choice == 1:
username = input('Enter your Username: ')
password = input('Enter password: ')
user_found = 0
mycursor.execute("SELECT user_name FROM user_info")
record = mycursor.fetchall()
for x in record:
for y in x:
if y == username:
mycursor.execute("SELECT user_password FROM user_info")
record1 = mycursor.fetchall()
for a in record1:
for b in a:
if b == password:
user_found = 1
if user_found == 1:
print("Welcome ",username, "!")
package_choice()
else:
break
elif user_found==0:
print("Wrong Password/Username, Please try again.")
break
elif choice == 2:
print("Register-")
mycursor = mydb.cursor()
name = input("Enter your Name: ")
user_name = input("Enter Username: ")
password = input("Enter Password: ")
sql = "INSERT INTO user_info (user_info_name,user_name,user_password) VALUES (%s,%s,%s)"
val = (name,user_name,password)
mycursor.execute(sql,val)
mydb.commit()
print(mycursor.rowcount,"Successfully Registered. ")
else:
print("Wrong choice")