0% found this document useful (0 votes)
8 views2 pages

CS Project

Uploaded by

rajputsannidhya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

CS Project

Uploaded by

rajputsannidhya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

FOR MY SQL

CREATE DATABASE gst_billing_system;

USE gst_billing_system;

CREATE TABLE users (


user_id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL,
password VARCHAR(255) NOT NULL,
role ENUM('admin') NOT NULL
);

CREATE TABLE inventory (


item_id INT AUTO_INCREMENT PRIMARY KEY,
item_name VARCHAR(100) NOT NULL,
quantity INT NOT NULL,
price DECIMAL(10, 2) NOT NULL,
gst_rate DECIMAL(5, 2) NOT NULL
);

CREATE TABLE sales (


sale_id INT AUTO_INCREMENT PRIMARY KEY,
item_id INT,
quantity INT,
total_price DECIMAL(10, 2),
sale_date DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (item_id) REFERENCES inventory(item_id)
);

CREATE TABLE purchases (


purchase_id INT AUTO_INCREMENT PRIMARY KEY,
item_id INT,
quantity INT,
purchase_date DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (item_id) REFERENCES inventory(item_id)
);
DATABASE CONNECTION FOR PYTHON
import mysql.connector

def create_connection():
return mysql.connector.connect(
host="localhost",
user="your_username",
password="your_password",
database="gst_billing_system"
)
LOGIN MODULE
def login(username, password):
conn = create_connection()
cursor = conn.cursor()
cursor.execute("SELECT * FROM users WHERE username = %s", (username,))
user = cursor.fetchone()

if user and user[2] == password: # Assuming password is stored in user[2]


print("Login successful!")
return True
else:
print("Invalid username or password.")
return False
INVENTORY MANAGEMENT
def add_inventory(item_name, quantity, price, gst_rate):
conn = create_connection()
cursor = conn.cursor()
cursor.execute("INSERT INTO inventory (item_name, quantity, price, gst_rate) VALUES
(%s, %s, %s, %s)",
(item_name, quantity, price, gst_rate))
conn.commit()
print("Item added to inventory.")
cursor.close()
conn.close()

def update_inventory(item_id, quantity):


conn = create_connection()
cursor = conn.cursor()
cursor.execute("UPDATE inventory SET quantity = %s WHERE item_id = %s", (quantity,
item_id))
conn.commit()
print("Inventory updated.")
cursor.close()
conn.close()

def delete_inventory(item_id):
conn = create_connection()
cursor = conn.cursor()
cursor.execute("DELETE FROM inventory WHERE item_id = %s", (item_id,))
conn.commit()
print("Item deleted from inventory.")
cursor.close()
conn.close()

You might also like