#!/usr/local/bin/python "Add a URL & title to the hotlist database." import pg, sys, string def add(url, text): "Add the url and text to the database." db.query("insert into hotlist (URL, description, added, id) values " "(%s, %s, 'now', nextval('link_counter'))" % (pg._quote(url, None), pg._quote(text, None))) db = pg.connect('hotlist') if len(sys.argv) > 1: add(sys.argv[1], string.join(sys.argv[2:])) else: for line in sys.stdin.readlines(): words = string.split(line) try: add(words[0], string.join(words[1:])) except: print "Failed on:", line raise