Professional Documents
Culture Documents
INFORMATICS PRACTICES
th
CLASS:12
PROJECT FILE
SESSION 2023-
24
STUDENT: TEACHER:
Anurag Nayak Mr. SANJAYA KUMAR SENAPATI
Class:12‘a’ MSc, MCA, M.Phil.
HOD COMPUTER
CERTIFICATE
Secondly, I am making this project not only for marks but to also
increase my knowledge.
INDEX
7
7. Security: It's crucial to handle database interactions
securely, especially when dealing with user inputs. Prepared
statements or parameterized queries should be used to
prevent SQL injection attacks, where malicious SQL code is
injected into user inputs.
8. Data Integrity: Maintaining data integrity within the
database is essential. This involves defining data constraints,
such as unique keys, foreign keys, and checks, to ensure
that data remains consistent and reliable.
9. Performance: Optimizing database queries and indexing
are important for efficient database operations. Python
provides profiling and optimization tools to help enhance
the performance of your database interactions.
8
CODING
import mysql.connector
from mysql.connector.cursor import MySQLCursor
#connect to database
mydb = mysql.connector.connect(
host = "localhost",
user ="root",
password= "",
database ="travel"
)
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM user_info")
record= mycursor.fetchall()
for x in record:
print(x)
import mysql.connector
from mysql.connector.cursor import MySQLCursor
#connect to database
mydb = mysql.connector.connect(
host = "localhost",
user ="root",
password= "",
database ="travel"
)
9
mycursor = mydb.cursor()
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:
12
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)"
13
val = (name,user_name,password)
mycursor.execute(sql,val)
mydb.commit()
print(mycursor.rowcount,"Successfully Registered. ")
else:
print("Wrong choice")
import mysql.connector
from mysql.connector.cursor import MySQLCursor
#connect to database
mydb = mysql.connector.connect(
host = "localhost",
user ="root",
password= "",
database ="travel"
)
mycursor = mydb.cursor()
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: ")
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 number of the package
14
you want: ")
sql1 = ("INSERT INTO customer_info VALUES(%s,%s,%s,
%s)")
values1 = (username,package_id,no_of_people,price)
mycursor.execute(sql1,values1)
elif choice == 2:
print("B")
else:
print("Wrong choice")
17
OUTPUT
18
Conclusion
19
Reference
https://Github.com
https://en.m.wikipedia.org
https://google.com
Informatics practices by Sumita Arora class 12
Informatics Practices - Class 12: Reeta Sahoo
APOLOGY
Respected Examiner,
Best regards,
Anurag Nayak