instancemethod
Gert Cuykens
gert.cuykens at gmail.com
Sun Jan 21 21:25:06 EST 2007
import MySQLdb
class Db:
_db=-1
_cursor=-1
rowcount=-1
def __init__(self,server,user,password,database):
self._db=MySQLdb.connect(server , user , password , database)
self._cursor=self._db.cursor()
def excecute(self,cmd):
self._cursor.execute(cmd)
self._db.commit()
self.rowcount=int(self._cursor.rowcount())
def fetchone(self):
return self._cursor.fetchone()
def close(self):
self._cursor.close()
self._db.close()
if __name__ == '__main__':
gert=Db('localhost','root','*******','gert')
gert.excecute('select * from person')
for x in range(0,gert.rowcount):
print gert.fetchone()
gert.close()
Traceback (most recent call last):
File "Desktop/svn/db/Py/db.py", line 28, in <module>
gert.excecute('select * from person')
File "Desktop/svn/db/Py/db.py", line 17, in excecute
self.rowcount=int(self._cursor.rowcount())
TypeError: 'long' object is not callable
I guess i did something wrong again ? :)
More information about the Python-list
mailing list