summaryrefslogtreecommitdiffstats
path: root/Code/Server-Code/DbClass.py
diff options
context:
space:
mode:
Diffstat (limited to 'Code/Server-Code/DbClass.py')
-rw-r--r--[-rwxr-xr-x]Code/Server-Code/DbClass.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/Code/Server-Code/DbClass.py b/Code/Server-Code/DbClass.py
index a53987f..d937eb1 100755..100644
--- a/Code/Server-Code/DbClass.py
+++ b/Code/Server-Code/DbClass.py
@@ -4,8 +4,8 @@ import string
class DBMySQLConnection:
def __init__(self):
#initialize at the start all the user parameters
- self.usern = "selftest"
- self.passw = "selftest"
+ self.usern = "root"
+ self.passw = ""
self.host = "localhost"
self.db = "gsmselftesting"
self.connectionCreated = 0
@@ -19,7 +19,7 @@ class DBMySQLConnection:
def connectDB(self):
try:
- #try the connection
+ #try to connect
self.datBaseConn=MySQLdb.connect(self.host,self.usern, self.passw,self.db)
self.datBaseConn.paramstyle = 'format'
self.cur = self.datBaseConn.cursor() #make the cursor, used for sending queries
@@ -115,7 +115,7 @@ class DBMySQLConnection:
return 2 #the table doesn't exist
if debugMode == 1:
print str(e)
- return 3 #some error happened 07667929147--Fitri
+ return 3 #some error happened
else:
return 0 #I am not connected
def deviceList(self): # taking all device list and put it in the list
@@ -171,6 +171,13 @@ class DBMySQLConnection:
def updateGSMDevice(self, deviceName, newPortName, newNumber):
if self.connectionCreated == 1:
try:
+ try:
+ #delete old device portName which assign to this port, to prevent double port address in the table.
+ stmt = "UPDATE DeviceAddressTable SET portName = 'missing' WHERE portName = '"+newPortName+"'"
+ self.cur.execute(stmt)
+ except ValueError:
+ print "Error execute query"
+
stmt = "UPDATE DeviceAddressTable SET portName = '"+ newPortName + "', number = '"+ newNumber+ "' WHERE deviceName = '" + deviceName+ "'"
self.cur.execute(stmt)
return 1