summaryrefslogtreecommitdiffstats
path: root/For Weekly Test/12-09-2011/DbClass.py
diff options
context:
space:
mode:
Diffstat (limited to 'For Weekly Test/12-09-2011/DbClass.py')
-rw-r--r--For Weekly Test/12-09-2011/DbClass.py54
1 files changed, 1 insertions, 53 deletions
diff --git a/For Weekly Test/12-09-2011/DbClass.py b/For Weekly Test/12-09-2011/DbClass.py
index f25afe2..d312b63 100644
--- a/For Weekly Test/12-09-2011/DbClass.py
+++ b/For Weekly Test/12-09-2011/DbClass.py
@@ -98,11 +98,7 @@ class DBMySQLConnection:
if self.connectionCreated == 1:
try:
successful = self.cur.execute("SELECT `deviceIP`,`number`, `username`, `password`, `server` FROM DeviceAddressTable where `deviceName`=%s", deviceName)
- output = self.cur.fetchall() #get the mysql response
- #parse the output from the mysql by creating a list
- #with lists where each attribue(column) gets independent
- #element of the list
-
+ output = self.cur.fetchall()
deviceAddr = ''
for record in output:
columns = list()
@@ -187,54 +183,6 @@ class DBMySQLConnection:
return 0
- def insertTaskIn2(self, fromDevice, toDevice, taskNo, status):
- if self.connectionCreated == 1:
- try:
- #I used here a transaction since I want the mysql to execute a few commands and tell me was it successful rather than to execute some and there happens a mistake and one part is updated and the other isn't
- newQuery = "START TRANSACTION; INSERT INTO `TaskTable` (`taskNo`, `from`, `to`, `status`) VALUES ('" + str(taskNo) + "', '" + str(fromDevice) + "', '" + str(toDevice) +"', '0'); SELECT @taskID := LAST_INSERT_ID(); INSERT INTO `TempTaskTable` (`taskID`, `taskNo`, `from`, `to`,`status` ) VALUES (@taskID, '" + str(taskNo) + "', '" + str(fromDevice) + "', '"+ str(toDevice) + "', '"+ str(status) + "'); COMMIT;"
-
-
- successful = self.cur.execute(newQuery)
- output = self.cur.fetchone()
-
-
- #without closing the cursos we get a MySQL error, the mistake is an internal mistak of the MySQLdb python library
- # self.cur.close()
- # self.cur = self.datBaseConn.cursor()
-
- while self.cur.nextset() is not None: pass
-
- newQuery1 = 'SELECT taskID FROM `TempTaskTable` ORDER BY taskID DESC LIMIT 1';
- successful1 = self.cur.execute(newQuery1)
- record = self.cur.fetchone()
-
- columns = list()
- for entry in record:
- columns.append(str(entry))
-
- columns.append(str(taskNo))
- columns.append(str(fromDevice))
- columns.append(str(toDevice))
- columns.append(str(status))
- #columns.append(str(0))
- self.tasksList.append(columns)
-
- return 1
-
- if debugMode == 1:
- print output
-
- except MySQLdb.Error, e:
- error = str(e)
- if debugMode == 1:
- print str(e)
- if error[1:5] == '1062':
- return 2 #duplicate entry for the key
- return 3
- else:
- return 0
-
-
def errorCode(self,code):
if self.connectionCreated == 1:
try: