instancemethod
Gert Cuykens
gert.cuykens at gmail.com
Mon Jan 22 15:55:13 EST 2007
Reading all of the above this is the most simple i can come too.
import MySQLdb
class Db:
def __init__(self,server,user,password,database):
self._db=MySQLdb.connect(server , user , password , database)
self._db.autocommit(True)
self.cursor=self._db.cursor()
def excecute(self,cmd):
self.cursor.execute(cmd)
self.rowcount=int(self.cursor.rowcount)
def close(self):
self.cursor.close()
self._db.close()
def __del__(self):
try:
self.close()
except:
pass
if __name__ == '__main__':
gert=Db('localhost','root','******','gert')
gert.excecute('select * from person')
for row in gert.cursor:
print row
This must be the most simple it can get right ?
PS i didn't understand the __getattr__ quit well but i thought it was
just to overload the privies class
More information about the Python-list
mailing list