Пример #1
0
    def writeData(self, req, tblName):
        try:
            res = writeDataSrvResponse()
            db_username, db_password = self.getLogin()
            con = mdb.connect('localhost', db_username, db_password,
                              'RappStore')
            cur = con.cursor()
            returncols = self.constructCommaColumns(req.req_cols)
            if (len(returncols) > 1):
                returncols = "(" + returncols + ")"
            print returncols
            values = ""
            for i in range(len(req.req_data)):
                if (i == 0):
                    values = values + "(" + self.constructCommaColumns(
                        req.req_data[i].s) + ")"
                else:
                    values = values + ",(" + self.constructCommaColumns(
                        req.req_data[i].s) + ")"

            query = "Insert into " + tblName + " " + returncols + " values " + values
            cur.execute("LOCK TABLES " + tblName + " WRITE")
            cur.execute(query)
            cur.execute("UNLOCK TABLES")
            res.success.data = True
            res.trace.append("Success")
        except mdb.Error, e:
            res.trace.append(
                ("Database Error %d: %s" % (e.args[0], e.args[1])))
            res.success.data = False
            print "Error %d: %s" % (e.args[0], e.args[1])
Пример #2
0
  def writeData(self,req,tblName):
    #generic db write function
    try:
      res = writeDataSrvResponse()
      db_username,db_password=self.getLogin()
      con = mdb.connect('localhost', db_username, db_password, 'RappStore');
      cur = con.cursor()
      returncols=self.constructCommaColumns(req.req_cols)
      if (len(returncols)>1):
        returncols="("+returncols+")"
      print returncols
      values=""
      for i in range(len(req.req_data)):
        if (i==0):
          values=values+"("+self.constructCommaColumns(req.req_data[i].s)+")"
        else:
          values=values+",("+self.constructCommaColumns(req.req_data[i].s)+")"

      #print values
      query="Insert into "+tblName+" "+ returncols+" values "+values
      #print query
      cur.execute("LOCK TABLES "+tblName+" WRITE")
      cur.execute(query)
      cur.execute("UNLOCK TABLES")
      res.success.data=True
      res.trace.append("Success")
    except mdb.Error, e:
      res.trace.append(("Database Error %d: %s" % (e.args[0],e.args[1])))
      res.success.data=False
      print "Error %d: %s" % (e.args[0],e.args[1])
Пример #3
0
 def tblUsersOntologyInstancesWriteDataHandler(self, req):
     res = writeDataSrvResponse()
     res = self.writeData(req, "tblUsersOntologyInstances")
     return res
Пример #4
0
 def tblAppsRobotsWriteDataHandler(self, req):
     res = writeDataSrvResponse()
     res = self.writeData(req, "tblAppsRobots")
     return res
Пример #5
0
 def tblRappWriteDataHandler(self, req):
     res = writeDataSrvResponse()
     res = self.writeData(req, "tblRapp")
     return res
Пример #6
0
 def tblUsersOntologyInstancesWriteDataHandler(self,req):
   res = writeDataSrvResponse()
   res=self.writeData(req,"tblUsersOntologyInstances")
   return res
Пример #7
0
 def tblAppsRobotsWriteDataHandler(self,req):
   res = writeDataSrvResponse()
   res=self.writeData(req,"tblAppsRobots")
   return res
Пример #8
0
 def tblRappWriteDataHandler(self,req):
   res = writeDataSrvResponse()
   res=self.writeData(req,"tblRapp")
   return res
Пример #9
0
 def tblCloudAgentServiceArgumentsWriteDataHandler(self,req):
   res = writeDataSrvResponse()
   res=self.writeData(req,"cloud_agent_service_arguments")
   return res
Пример #10
0
 def tblCloudAgentWriteDataHandler(self,req):
   res = writeDataSrvResponse()
   res=self.writeData(req,"cloud_agent")
   return res
Пример #11
0
 def tblUserWriteDataHandler(self,req):
   res = writeDataSrvResponse()
   res=self.writeData(req,"users")
   return res