44 – Real-World Python Projects – QR Code Inventory System

This project builds a complete inventory management system using QR codes, Python, and a database.

Perfect for:

  • Shops / warehouses
  • Office asset tracking
  • Home inventory
  • Library / equipment logs
  • Event management

๐Ÿง  What You Will Build

Your QR Inventory System will:

โœ” Generate QR codes for each product

โœ” Scan QR codes to update stock

โœ” Maintain a database (CSV/SQLite)

โœ” Track product details (name, ID, price, quantity)

โœ” Add/Remove/Update inventory

โœ” Streamlit Dashboard (optional)

โœ” Logging system


๐Ÿงฐ Tech Stack

  • Python
  • qrcode (generate QR codes)
  • opencv-python (scan QR codes)
  • pyzbar (decode QR codes)
  • SQLite/Pandas

Install:

pip install qrcode opencv-python pyzbar pandas

๐Ÿ“ Folder Structure

QRInventory/
โ”‚โ”€โ”€ generate_qr.py
โ”‚โ”€โ”€ scan_qr.py
โ”‚โ”€โ”€ inventory.csv
โ”‚โ”€โ”€ qr_codes/

๐Ÿ“Œ 1. Inventory File (inventory.csv)

id,name,price,qty
101,Keyboard,800,12
102,Mouse,400,20
103,Laptop,55000,5

๐Ÿงฉ 2. QR Code Generator (generate_qr.py)

import qrcode
import pandas as pd
import os

df = pd.read_csv("inventory.csv")
os.makedirs("qr_codes", exist_ok=True)

for _, row in df.iterrows():
    data = f"{row['id']}|{row['name']}|{row['price']}|{row['qty']}"
    img = qrcode.make(data)
    img.save(f"qr_codes/{row['id']}.png")

print("QR Codes Generated!")

โœ” Each product gets a QR code
โœ” Encodes ID, name, price, quantity


๐Ÿงฉ 3. QR Code Scanner + Inventory Updater (scan_qr.py)

import cv2
from pyzbar.pyzbar import decode
import pandas as pd

def update_stock(product_id):
    df = pd.read_csv("inventory.csv")
    df.loc[df["id"] == int(product_id), "qty"] += 1
    df.to_csv("inventory.csv", index=False)
    print("Stock updated!")

cap = cv2.VideoCapture(0)

print("Scan QR Code...")

while True:
    _, frame = cap.read()
    for code in decode(frame):
        data = code.data.decode("utf-8")
        pid, name, price, qty = data.split("|")
        print(f"Scanned โ†’ {name} (ID: {pid})")

        update_stock(pid)
        cap.release()
        cv2.destroyAllWindows()
        exit()

    cv2.imshow("QR Scanner - Press Q to Quit", frame)

    if cv2.waitKey(1) & 0xFF == ord("q"):
        break

cap.release()
cv2.destroyAllWindows()

โœ” Scans QR code
โœ” Reads product info
โœ” Automatically updates database


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *