import MySQLdb
import sys
from libdesklets.controls import Control
from IDBConnection import IDBConnection
class DBConnection(Control, IDBConnection):
host = 'xxxx'
user = 'xxxx'
passwd = 'xxxx'
db = 'xxxx'
def __init__(self):
Control.__init__(self)
pass
def __get_dbconnection(self):
db = MySQLdb.connect(self.host, self.user, self.passwd, self.db)
return db
def __insert(self):
db = self.__get_dbconnection()
cursor = db.cursor()
cursor.execute("INSERT INTO Usernotes (UID, NID, Inhalt) VALUES (3, 1, 'text');")
cursor.close()
db.close()
def __select(self):
db = self.__get_dbconnection()
cursor = db.cursor()
cursor.execute("SELECT Inhalt FROM Usernotes WHERE UID = 1 AND NID = 1;")
cursor.close()
db.close()
def __update(self):
db = self.__get_dbconnection()
cursor = db.cursor()
cursor.execute("UPDATE Usernotes SET Inhalt = 'inserttest' WHERE UID = 1 AND NID = 2;")
cursor.close()
db.close()
insert = property(__insert, doc="insert into database")
select = property(__select, doc="select from database")
update = property(__update, doc="update database")
def get_class(): return DBConnection
The code above is a Control to work with a mysql-Database for Linux gdesklets (thats where import Control and import IDBConnection is coming from). So when we call the properties from another file (dbc.insert() / dbc.select() / dbc.update()) we get the error “‘NoneType’ object is not callable”. If we add return types we get “‘ReturnType’ object is not callable”. The functions are working and the database operations are done but the display-file (where the functions are called) crashes after the exception.
Hopefully someone can help us here.
Your query returned an empty set, or the value of a column was null.
Without a specific error, it’s more difficult to say, but I think your select is coming up with an empty set.
Your insert sets UID = 3 and NID = 1, your update is looking to change where UID = 1 and NID 2, but your select is looking for UID = 1 and NID = 1.
I’m guessing that’s where it’s bombing.