All pastes #986670 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-04-15 22:57 UTC
rendered paste body
## devlin's python framework
# author: Devlin Zaussome
# copyright: 2008 Devlin Zaussome
import cgi
import MySQLdb

global get
get = cgi.FieldStorage().getvalue

class Templating:
    '''Templating class'''
    default_content_type = "text/html"

    def __init__(self, content_type=self.default_content_type):
        print "Content-type: %s\n" % content_type

class MySQL:
    '''MySQL abstraction class.'''
    connection = False
    cursor = False

    def __init__(self, server="localhost", username, password, database):
        '''Initialized the class; connects to the database.'''
        self.connection = MySQLdb.connect(server, username, password, database)
        
    def execute(query):
        '''Executes a MySQL query.'''
        self.cursor = self.connection.cursor()
        self.cursor.execute(query)

    def fetch(query):
        '''Fetches the results from a MySQL query.'''
        self.cursor = self.connection.cursor()
        self.cursor.execute(query)
        return self.cursor.fetchall()