Category editing implemented
[biaweb_qt.git] / biaweb_db.py
index 2c8e6cd..4487339 100644 (file)
@@ -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):