X-Git-Url: https://harishankar.org/repos/?p=biaweb_qt.git;a=blobdiff_plain;f=biaweb_db.py;fp=biaweb_db.py;h=c1d5e60db222804c0eac91012849a2982f8a0dc2;hp=9b7cb10f72d336440b3fd639812710ecf34525e5;hb=de54d2eb3b283030bd98f7a1f6d056ce2e56b4d7;hpb=f37ae5235dba470cf02e25a885b83a2bc9c78694 diff --git a/biaweb_db.py b/biaweb_db.py index 9b7cb10..c1d5e60 100644 --- a/biaweb_db.py +++ b/biaweb_db.py @@ -207,6 +207,24 @@ def get_configuration (dbname): except sqlite3.Error: return False +# Function to get articles from a category or all articles (inner join with categories to get category stub) +def site_articles (dbname, catid = None): + try: + conn = sqlite3.connect (dbname) + c = conn.cursor () + if catid is None: + c.execute ("SELECT * FROM articles INNER JOIN categories ON articles.cid=categories.cid \ + ORDER BY cdate DESC;") + else: + c.execute ("SELECT * FROM articles INNER JOIN categories ON articles.cid=categories.cid \ + WHERE articles.cid=? ORDER BY cdate DESC;", (catid,)) + conn.commit () + rows = c.fetchall () + conn.close () + return rows + except sqlite3.Error: + return False + # Function to get the latest articles (inner join with categories to get category stub) def site_latest_articles (dbname, num_arts): try: