{"id":264,"date":"2025-11-21T15:25:15","date_gmt":"2025-11-21T15:25:15","guid":{"rendered":"https:\/\/codetypingpro.com\/?p=264"},"modified":"2025-11-21T15:25:15","modified_gmt":"2025-11-21T15:25:15","slug":"44-real-world-python-projects-qr-code-inventory-system","status":"publish","type":"post","link":"https:\/\/codetypingpro.com\/?p=264","title":{"rendered":"44 &#8211; Real-World Python Projects &#8211; QR Code Inventory System"},"content":{"rendered":"\n<h6 class=\"wp-block-heading\"><\/h6>\n\n\n\n<p class=\"wp-block-paragraph\">This project builds a complete inventory management system using <strong>QR codes<\/strong>, Python, and a database.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Perfect for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Shops \/ warehouses<\/li>\n\n\n\n<li>Office asset tracking<\/li>\n\n\n\n<li>Home inventory<\/li>\n\n\n\n<li>Library \/ equipment logs<\/li>\n\n\n\n<li>Event management<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83e\udde0 <strong>What You Will Build<\/strong><\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Your QR Inventory System will:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u2714 Generate QR codes for each product<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">\u2714 Scan QR codes to update stock<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">\u2714 Maintain a database (CSV\/SQLite)<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">\u2714 Track product details (name, ID, price, quantity)<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">\u2714 Add\/Remove\/Update inventory<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">\u2714 Streamlit Dashboard (optional)<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">\u2714 Logging system<\/h3>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83e\uddf0 Tech Stack<\/h1>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Python<\/strong><\/li>\n\n\n\n<li><strong>qrcode<\/strong> (generate QR codes)<\/li>\n\n\n\n<li><strong>opencv-python<\/strong> (scan QR codes)<\/li>\n\n\n\n<li><strong>pyzbar<\/strong> (decode QR codes)<\/li>\n\n\n\n<li><strong>SQLite\/Pandas<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Install:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install qrcode opencv-python pyzbar pandas\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udcc1 Folder Structure<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>QRInventory\/\n\u2502\u2500\u2500 generate_qr.py\n\u2502\u2500\u2500 scan_qr.py\n\u2502\u2500\u2500 inventory.csv\n\u2502\u2500\u2500 qr_codes\/\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udccc 1. <strong>Inventory File (inventory.csv)<\/strong><\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>id,name,price,qty\n101,Keyboard,800,12\n102,Mouse,400,20\n103,Laptop,55000,5\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83e\udde9 2. <strong>QR Code Generator (generate_qr.py)<\/strong><\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>import qrcode\nimport pandas as pd\nimport os\n\ndf = pd.read_csv(\"inventory.csv\")\nos.makedirs(\"qr_codes\", exist_ok=True)\n\nfor _, row in df.iterrows():\n    data = f\"{row&#91;'id']}|{row&#91;'name']}|{row&#91;'price']}|{row&#91;'qty']}\"\n    img = qrcode.make(data)\n    img.save(f\"qr_codes\/{row&#91;'id']}.png\")\n\nprint(\"QR Codes Generated!\")\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u2714 Each product gets a QR code<br>\u2714 Encodes ID, name, price, quantity<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83e\udde9 3. <strong>QR Code Scanner + Inventory Updater (scan_qr.py)<\/strong><\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>import cv2\nfrom pyzbar.pyzbar import decode\nimport pandas as pd\n\ndef update_stock(product_id):\n    df = pd.read_csv(\"inventory.csv\")\n    df.loc&#91;df&#91;\"id\"] == int(product_id), \"qty\"] += 1\n    df.to_csv(\"inventory.csv\", index=False)\n    print(\"Stock updated!\")\n\ncap = cv2.VideoCapture(0)\n\nprint(\"Scan QR Code...\")\n\nwhile True:\n    _, frame = cap.read()\n    for code in decode(frame):\n        data = code.data.decode(\"utf-8\")\n        pid, name, price, qty = data.split(\"|\")\n        print(f\"Scanned \u2192 {name} (ID: {pid})\")\n\n        update_stock(pid)\n        cap.release()\n        cv2.destroyAllWindows()\n        exit()\n\n    cv2.imshow(\"QR Scanner - Press Q to Quit\", frame)\n\n    if cv2.waitKey(1) &amp; 0xFF == ord(\"q\"):\n        break\n\ncap.release()\ncv2.destroyAllWindows()\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u2714 Scans QR code<br>\u2714 Reads product info<br>\u2714 Automatically updates database<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This project builds a complete inventory management system using QR codes, Python, and a database. Perfect for: \ud83e\udde0 What You Will Build Your QR Inventory System will: \u2714 Generate QR codes for each product \u2714 Scan QR codes to update stock \u2714 Maintain a database (CSV\/SQLite) \u2714 Track product details (name, ID, price, quantity) \u2714 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-264","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/264","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=264"}],"version-history":[{"count":1,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/264\/revisions"}],"predecessor-version":[{"id":265,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/264\/revisions\/265"}],"wp:attachment":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}