X-Git-Url: https://harishankar.org/repos/?p=biaweb_qt.git;a=blobdiff_plain;f=biaweb_db.py;fp=biaweb_db.py;h=4487339ae16bf3ca0ba570d46f6ee12b2db3770f;hp=2c8e6cdf3fae529c6ff91b6272f5c284a82ebde4;hb=8c9cfa39545fd48c66d4e795a6d2d7faa396c6c9;hpb=3632ca174c91a33db13178bc19ad2f93473b52c0 diff --git a/biaweb_db.py b/biaweb_db.py index 2c8e6cd..4487339 100644 --- a/biaweb_db.py +++ b/biaweb_db.py @@ -5,6 +5,32 @@ import sqlite3 import os import os.path +# function to get a category from the database +def get_category (dbname, catid): + try: + conn = sqlite3.connect (dbname) + c = conn.cursor () + c.execute ("SELECT * FROM categories WHERE cid=?", (catid,)) + conn.commit () + cat = c.fetchone () + conn.close () + return cat + except sqlite3.Error: + return False + +# function to update a category +def update_category (dbname, catid, cat_name, cat_desc, cat_stub): + try: + conn = sqlite3.connect (dbname) + c = conn.cursor () + c.execute ("UPDATE categories SET name=?, desc=?, stub=? WHERE cid=?;", + (cat_name, cat_desc, cat_stub, catid)) + conn.commit () + conn.close () + return True + except sqlite3.Error: + return False + # function to set the configuration and update the database def set_configuration (dbname, site_title, site_url, keywords, description, copyright, num_rss, dest_path):