partsdb

electronic parts inventory
git clone https://git.e1e0.net/partsdb.git
Log | Files | Refs | README | LICENSE

commit e71d4561b55045e7f709836a4d6ea34004ebb393
parent 40a03907819f444905c070ec45efb9c289149962
Author: Paco Esteban <paco@e1e0.net>
Date:   Sat, 30 Oct 2021 20:06:47 +0200

list categories, id is valid now as well as name

Diffstat:
Mpartsdb/database.py | 4++--
Mpartsdb/partsdb.py | 2+-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/partsdb/database.py b/partsdb/database.py @@ -22,7 +22,7 @@ LIST_PARTS_CATEGORY_QUERY = """ FROM parts as p, categories as c INNER JOIN categories ON p.category_id = c.id - WHERE c.name = ? + WHERE c.name = ? OR c.id = ? GROUP BY p.id """ INSERT_PART_QUERY = """ @@ -108,7 +108,7 @@ class PartsDB(): def list_parts_by_category(self, category): c = self.conn.cursor() - c.execute(LIST_PARTS_CATEGORY_QUERY, (category,)) + c.execute(LIST_PARTS_CATEGORY_QUERY, (category, category)) return c.fetchall() def new_part(self, part): diff --git a/partsdb/partsdb.py b/partsdb/partsdb.py @@ -228,7 +228,7 @@ def main(): # list ap_list = asp.add_parser("list", help="List all parts from a category (or all)") - ap_list.add_argument("category", help="Category Name") + ap_list.add_argument("category", help="Category Name or ID") ap_list.add_argument("-o", dest='output', choices=['full', 'short', 'json'], default='full', help="Short output")