Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import mysql.connector
- import getpass
- import cgi
- import sys
- mysqlpass = getpass.getpass("password for mysql: ", sys.stderr)
- cnx = mysql.connector.connect(user='root',
- password=mysqlpass,
- host='127.0.0.1',
- database='scuttle')
- class Bookmark(object):
- def __init__(self, title, description, address):
- self.tags = []
- self.title = title
- self.description = description
- self.address = address
- cursor = cnx.cursor()
- cursor.execute("SELECT bTitle,bDescription,bAddress,bId FROM sc_bookmarks;")
- bookmarks = dict((bId, Bookmark(bTitle,bDescription,bAddress))
- for (bTitle,bDescription,bAddress,bId) in cursor)
- cursor.close()
- cursor = cnx.cursor()
- cursor.execute("SELECT bId,tag FROM sc_tags;")
- for (bId,tag) in cursor:
- if not tag.startswith('system:'):
- bookmarks[bId].tags.append(tag)
- cursor.close()
- for bookmark in bookmarks.values():
- print u'<A DESCRIPTION="{description}" TAGS="{tags}" HREF="{url}">{title}</A>'.format(
- tags=cgi.escape(','.join(bookmark.tags)),
- url=bookmark.address,
- title=cgi.escape(bookmark.title),
- description=cgi.escape(bookmark.description)).encode('utf-8')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement