from datetime import datetime

from django.db.backends import util

import sqlparse

from debug_toolbar.utils import ms_from_timedelta


class PrintQueryWrapper(util.CursorDebugWrapper):
    def execute(self, sql, params=()):
        starttime = datetime.now()
        try:
            return self.cursor.execute(sql, params)
        finally:
            raw_sql = self.db.ops.last_executed_query(self.cursor, sql, params)
            execution_time = datetime.now() - starttime
            print sqlparse.format(raw_sql, reindent=True),
            print ' [%.2fms]' % (ms_from_timedelta(execution_time),)
            print

util.CursorDebugWrapper = PrintQueryWrapper

@@ -1,12 +1,51 @@
+from __future__ import print_function%0A%0A
 from datetim
@@ -480,24 +480,42 @@
 tion_time = 
+ms_from_timedelta(
 datetime.now
@@ -528,16 +528,17 @@
 tarttime
+)
 %0A       
@@ -542,21 +542,31 @@
         
-print
+formatted_sql =
  sqlpars
@@ -597,17 +597,16 @@
 nt=True)
-,
 %0A       
@@ -619,10 +619,12 @@
 rint
- '
+('%25s
  %5B%25.
@@ -633,34 +633,31 @@
 ms%5D' %25 (
-ms_from_timedelta(
+formatted_sql, 
 executio
@@ -667,28 +667,10 @@
 ime)
-,
 )%0A
-            print
 %0A%0Aut

Replace print statement by print function.