Implemented category delete and more
[biaweb_qt.git] / biaweb_db.py
index 4487339..9caad08 100644 (file)
@@ -31,6 +31,19 @@ def update_category (dbname, catid, cat_name, cat_desc, cat_stub):
        except sqlite3.Error:
                return False
 
+# function to remove a category
+def remove_category (dbname, catid):
+       try:
+               conn = sqlite3.connect (dbname)
+               c = conn.cursor ()
+               c.execute ("DELETE FROM categories WHERE cid=?;", (catid,))
+               c.execute ("DELETE FROM articles WHERE cid=?;", (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):