Browse Source

Prise en charge de la clause bindparam dans sqlquerybuilder.py

To-Do: tester
Driky 9 years ago
parent
commit
49994da98f
1 changed files with 17 additions and 3 deletions
  1. 17
    3
      Database/sqlquerybuilder.py

+ 17
- 3
Database/sqlquerybuilder.py View File

54
         """
54
         """
55
         self.proxy = self.proxy.values(arg)
55
         self.proxy = self.proxy.values(arg)
56
 
56
 
57
-    def Execute(self):
57
+    def Execute(self, bindedparam):
58
         """
58
         """
59
         Execute the sql query constructed in the proxy and return the result.
59
         Execute the sql query constructed in the proxy and return the result.
60
         If no query then return False.
60
         If no query then return False.
61
         @return: query result on success else False
61
         @return: query result on success else False
62
         """
62
         """
63
         if(self.proxy.__str__().split() == 'SELECT'):
63
         if(self.proxy.__str__().split() == 'SELECT'):
64
-            return self.sqlwrapper.rconn.execute(self.proxy)
64
+            if('bindparam' in self.proxy.__str__()):
65
+                #on test separement la présence de la clause bindparam et le type de l'argument correspondant
66
+                #car si la clause est présente mais que l'argument est defectueux on doit renvoyer False et non pas executer la requete
67
+                if(type(bindedparam) is list and type(bindedparam[0]) is dict):
68
+                    return self.sqlwrapper.rconn.execute(self.proxy, bindedparam)
69
+                else:
70
+                    return False
71
+            else:
72
+                return self.sqlwrapper.rconn.execute(self.proxy)
65
         elif(self.proxy is not None):
73
         elif(self.proxy is not None):
66
-            return self.sqlwrapper.wconn.execute(self.proxy)
74
+            if('bindparam' in self.proxy.__str__()):
75
+                if(type(bindedparam) is list and type(bindedparam[0]) is dict):
76
+                    return self.sqlwrapper.wconn.execute(self.proxy, bindedparam)
77
+                else:
78
+                    return False
79
+            else:
80
+                return self.sqlwrapper.wconn.execute(self.proxy)
67
         else:
81
         else:
68
             return False
82
             return False
69
 
83
 

Loading…
Cancel
Save