summaryrefslogtreecommitdiffstats
path: root/notFinishedCode
diff options
context:
space:
mode:
authorRefik Hadzialic2011-07-15 20:38:59 +0200
committerRefik Hadzialic2011-07-15 20:38:59 +0200
commitc5c321e742378effc82d44395683ad33444a68ad (patch)
treeca3e7e00a279fbda1510712e52d46424afb53d49 /notFinishedCode
parentchanged it to make it work (diff)
downloadgsm-selftest-c5c321e742378effc82d44395683ad33444a68ad.tar.gz
gsm-selftest-c5c321e742378effc82d44395683ad33444a68ad.tar.xz
gsm-selftest-c5c321e742378effc82d44395683ad33444a68ad.zip
debugged the function responsible for inserting new tasks in the temporary and normal task table!
Diffstat (limited to 'notFinishedCode')
-rw-r--r--notFinishedCode/dbClass.py41
1 files changed, 32 insertions, 9 deletions
diff --git a/notFinishedCode/dbClass.py b/notFinishedCode/dbClass.py
index ebdf73c..f2a9afb 100644
--- a/notFinishedCode/dbClass.py
+++ b/notFinishedCode/dbClass.py
@@ -1,6 +1,6 @@
import MySQLdb
import string
-from time import sleep
+
class DBMySQLConnection:
def __init__(self, username, password, host, dbname):
#initialize at the start all the user parameters
@@ -11,7 +11,7 @@ class DBMySQLConnection:
self.connectionCreated = 0
self.tasksList = list()
global debugMode
- debugMode = 1
+ debugMode = 0
def connectDB(self):
try:
@@ -216,17 +216,31 @@ class DBMySQLConnection:
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`) VALUES (@taskID, '" + str(taskNo) + "', '" + str(fromDevice) + "', '"+ str(toDevice) + "'); COMMIT;"
-
- newQuery1 = 'SELECT taskID FROM `TempTaskTable` ORDER BY taskID DESC LIMIT 1';
+
successful = self.cur.execute(newQuery)
- #self.datBaseConn.commit()
output = self.cur.fetchone()
- #print 'izlaz', output
-# successful1 = self.cur.execute(newQuery1)
-# output1 = self.cur.fetchone()
- #print output1
+
+ #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))
+ self.tasksList.append(columns)
+
return 1
if debugMode == 1:
@@ -301,8 +315,17 @@ print "add a result to the table", x.addResult(4,34)
# print "call from to ", taskID , callFrom , callTo
print 'i am inserting into the table something', x.insertTaskIn2('gsm4','sip8',2)
+print 'i am inserting into the table something', x.insertTaskIn2('gsm4','sip8',2)
+print 'i am inserting into the table something', x.insertTaskIn2('gsm4','sip8',2)
+print 'i am inserting into the table something', x.insertTaskIn2('gsm4','sip8',2)
#-----------------------------------------------------------------------------------
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+for item in x.tasksList:
+ taskID = item[0]
+ taskNo = item[1]
+ callFrom = item[2]
+ callTo = item[3]
+ print "call from to ", taskID , callFrom , callTo, taskNo
print "close connection to the DB", x.closeDBConn()