You are on page 1of 21

HOLY CROSS SCHOOL

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

This is to certify that Anurag Nayak, student of class


12th 'A' of Holy Cross School, Balidih, Bokaro has
successfully completed the project “INVOICE
PROCESSING Using Python and MySQL” under the
guidance of Mr. SANJAYA KUMAR SENAPATI
during the year 2023-24.

We wish all the best in his career of success.

External examiner signature

Internal examiner signature School stamp/ principal signature


ACKNOWLEDGMENT

I would like to express my special thanks of gratitude To,


my teacher Mr. SANJAYA KUMAR SENAPATI
as well as our Principal Sr Kamla Paul who gave me the
golden opportunity to complete this wonderful project on
the topic “INVOICE PROCESSING Using Python and
MySQL “which also helped me in doing a lot of research
and,
I came to know about so many new things.

Secondly, I am making this project not only for marks but to also
increase my knowledge.
INDEX

Sno. Topic Page


no.
1. INTRODUCTION 1
2. CERTIFICATE 2
3. ACKNOWLEDGMENT 3
4. SOME KNOWLEDGE ABOUT PYTHON- 5-7
SQL DATABASE WOKINGS
5. CODING 8-16
6. OUTPUT 17
7. CONCLUSION 18
8. REFERENCE 19
9. APOLOGY 20
SOME KNOWLEAGE ABOUT PYTHON-SQL
DATABASE WOKINGS

Python is a versatile programming language that is widely used


for a variety of applications, including database work. When it
comes to working with databases in Python, there are several
libraries and frameworks available, but one of the most popular
and commonly used is the combination of Python and SQL.

Here are some key points about Python-SQL database work:

1. Database Libraries: Python provides several libraries and


modules for interacting with relational databases, including
SQLite, MySQL, PostgreSQL, and Oracle databases. Some of
the popular libraries for working with databases in Python
include SQLite3, psycopg2 (for PostgreSQL), mysql-
connector (for MySQL), and cx_Oracle (for Oracle
databases).
2. Database Connectivity: Python libraries provide functions
and methods to connect to a database. This connection
allows Python programs to send and retrieve data from the
database. Connection parameters such as the database
server's address, username, and password are typically
required.
6
3. SQL Queries: SQL (Structured Query Language) is used to
communicate with the database. Python allows you to
execute SQL queries, which include SELECT (for retrieving
data), INSERT (for adding data), UPDATE (for modifying
data), and DELETE (for removing data).
4. Database Abstraction: Some Python libraries provide
higher-level, more abstracted interfaces for working with
databases. For instance, Object-Relational Mapping (ORM)
frameworks like SQL Alchemy and Django's ORM make it
easier to work with databases by allowing you to interact
with databases using Python classes and objects rather than
writing raw SQL queries.
5. Data Retrieval and Manipulation: Python allows you to
fetch data from a database and manipulate it as needed.
You can process the data in various ways, including filtering,
sorting, and transforming it using Python's data
manipulation capabilities.
6. Error Handling: Python-SQL database work requires robust
error handling to deal with potential issues such as
connection problems, query errors, and data integrity
violations. Proper error handling ensures that your
application is resilient and reliable.

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.

In summary, Python-SQL database work is a fundamental aspect


of many applications, enabling them to store, retrieve, and
manipulate data efficiently and securely. Python's versatility and
the availability of robust libraries and frameworks make it a
popular choice for working with databases in various domains,
from web development to data analysis and beyond.

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()

print('Welcome to Rocket Travel Agency')


#LOGIN
username = input('Enter your Username: ')
password = input('Enter password: ')
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:
print("Welcome!")
else:
print("Wrong Password, try again")
break
break
else:
print('Wrong Username, try again')
break
import mysql.connector
from mysql.connector.cursor import MySQLCursor
#connect to database
10
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':
11
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:
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 == '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 number of the package
you want: ")
sql1 = ("INSERT INTO customer_info VALUES(%s,%s,%s,
%s)")
values1 = (username,package_id,no_of_people,price)
mycursor.execute(sql1,values1)
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"
)
15
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM package_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"
)
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. ")
print("Welcome to Rocket Travel Agency!")
print("1. Login (already existing user)")
16
print("2. Register(new user)")
choice = int(input("Select your choice: "))
if choice == 1:
print("a")

elif choice == 2:
print("B")

else:
print("Wrong choice")

17
OUTPUT

18
Conclusion

In conclusion, our Python-SQL invoice project has successfully


demonstrated the efficiency and reliability of using Python in
conjunction with SQL to manage invoices and financial data.

The Python-SQL invoice project stands as a testament to the


effectiveness of this powerful combination for financial
management. It not only streamlines invoice handling but also
provides a solid foundation for maintaining accurate financial
records, ensuring data integrity, and facilitating future growth
and analysis.

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,

I wanted to express my sincere apologies if there are any


mistakes in the project. If, by chance, any errors have occurred,
please forgive me. I always strive to do my best and deliver
high-quality work, and any oversight on my part was completely
unintentional.

Your understanding and patience are greatly appreciated. I'm


committed to rectifying any issues promptly and ensuring that
the project meets your expectations. Thank you for your
understanding.

Best regards,
Anurag Nayak

You might also like