Home - Python - CGI scripting and MySQL


#! /usr/local/bin/python
#
# db.py - localized database access for Dramatis Personae
#

import MySQL

class Connection:

  def __init__(self, hostname, username, databasename):
    self.dbConnection = MySQL.connect(hostname,username, '')
    self.dbConnection.selectdb(databasename)

  def do (self, strSQL):
    return self.dbConnection.do(strSQL)

  def qry (self, strSQL):
    return self.dbConnection.do(strSQL)

  def disconnect (self):
    self.dbConnection.close
    
  def ins (self, strSQL):
    self.dbConnection.do(strSQL)
   
  def upd (self, strSQL):
    self.dbConnection.do(strSQL)

  def escape(self, str):
    return MySQL.escape(str)

Changes


© 2000 Boudewijn Rempt