-
Notifications
You must be signed in to change notification settings - Fork 0
/
ext_Debug_SQL.py
39 lines (31 loc) · 1.1 KB
/
ext_Debug_SQL.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# coding: utf8
import GestionDB
from Utils.UTILS_Traduction import _
from ext_Extensions_automatiques import addModule, hasModule, message
VERSION = "_v0.0.0"
def Extension():
if not hasModule(__name__ + VERSION):
message(u"L'extension est correctement installée, " +
u"merci de redémarrer Noethys pour l'activer.")
return
message(u"Extension installée et activée.", __name__ + VERSION)
def Initialisation():
GestionDB.DB.ExecuterReq = ExecuterReq
addModule(__name__ + VERSION)
def ExecuterReq(self, req):
if self.echec == 1:
return False
# Pour parer le pb des () avec MySQL
if self.isNetwork:
req = req.replace("()", "(10000000, 10000001)")
try:
self.cursor.execute(req)
GestionDB.DICT_CONNEXIONS[self.IDconnexion].append(req)
except Exception as err:
err = str(err).encode("ascii", "replace")
req = req.encode("ascii", "replace")
message(err + u"\n\n" + req)
print(_(u"Requete SQL incorrecte :\n%s\nErreur detectee:\n%s") % (req, err))
return 0
else:
return 1