cubicweb/server/sources/native.py
changeset 12739 c6f8ca03718f
parent 12731 8e5f2c449e60
child 12756 d91c229de97f
--- a/cubicweb/server/sources/native.py	Tue Aug 20 22:45:46 2019 +0200
+++ b/cubicweb/server/sources/native.py	Wed Aug 21 02:10:12 2019 +0200
@@ -50,6 +50,7 @@
 from cubicweb.server.edition import EditedEntity
 from cubicweb.server.sources import AbstractSource, dbg_st_search, dbg_results
 from cubicweb.server.sources.rql2sql import SQLGenerator
+from cubicweb.misc.source_highlight import highlight
 from cubicweb.statsd_logger import statsd_timeit
 
 
@@ -67,12 +68,12 @@
         it's a function just so that it shows up in profiling
         """
         if server.DEBUG & server.DBG_SQL:
-            print('exec', query, args)
+            print('exec', highlight(query, "SQL"), args)
         try:
             self.cu.execute(str(query), args)
         except Exception as ex:
             print("sql: %r\n args: %s\ndbms message: %r" % (
-                query, args, ex.args[0]))
+                highlight(query, "SQL"), args, ex.args[0]))
             raise
 
     def fetchall(self):
@@ -685,7 +686,7 @@
         """
         cursor = cnx.cnxset.cu
         if server.DEBUG & server.DBG_SQL:
-            print('exec', query, args, cnx.cnxset.cnx)
+            print('exec', highlight(query, "SQL"), args, cnx.cnxset.cnx)
         try:
             # str(query) to avoid error if it's a unicode string
             cursor.execute(str(query), args)
@@ -748,7 +749,8 @@
         it's a function just so that it shows up in profiling
         """
         if server.DEBUG & server.DBG_SQL:
-            print('execmany', query, 'with', len(args), 'arguments', cnx.cnxset.cnx)
+            print('execmany', highlight(query, "SQL"), 'with', len(args), 'arguments',
+                  cnx.cnxset.cnx)
         cursor = cnx.cnxset.cu
         try:
             # str(query) to avoid error if it's a unicode string