Article editing fully implemented
[biaweb_qt.git] / biaweb_db.py
index 1946ad7..dd3e333 100644 (file)
@@ -6,6 +6,19 @@ import os
 import os.path
 import time
 
+# function to get an article from the database
+def get_article (dbname, artid):
+       try:
+               conn = sqlite3.connect (dbname)
+               c = conn.cursor ()
+               c.execute ("SELECT * FROM articles WHERE aid=?;", (artid,))
+               conn.commit ()
+               row = c.fetchone ()
+               conn.close ()
+               return row
+       except sqlite3.Error:
+               return False
+
 # function to create an article
 def create_article (dbname, title, summary, keywords, content, catid, stub, rating):
        # time of creation
@@ -23,6 +36,22 @@ def create_article (dbname, title, summary, keywords, content, catid, stub, rati
        except sqlite3.Error:
                return False
 
+# function to update an article
+def update_article (dbname, aid, title, summary, keywords, content, catid, stub, rating):
+       # modification time only to be updated
+       modtime = time.time ()
+       try:
+               conn = sqlite3.connect (dbname)
+               c = conn.cursor ()
+               c.execute ("UPDATE articles SET title=?, summary=?, keywords=?, content=?, mdate=?, cid=?, \
+                                       stub=?, rating=? WHERE aid=?;",
+                                       (title, summary, keywords, content, modtime, catid, stub, rating, aid))
+               conn.commit ()
+               conn.close ()
+               return True
+       except sqlite3.Error:
+               return False
+
 # function to delete an article
 def delete_article (dbname, artid):
        try: