#NEWLINE# def execute( self , sql , params = [ ] , print_all_errors = True ) : #NEWLINE# #INDENT# "\n        Executes the given SQL statement, with optional parameters.\n        If the instance's debug attribute is True, prints out what it executes.\n        " #NEWLINE# self . _possibly_initialise ( ) #NEWLINE# cursor = self . _get_connection ( ) . cursor ( ) #NEWLINE# if self . debug : #NEWLINE# #INDENT# print ( ( '   = %s' % sql ) , params ) #NEWLINE# #UNINDENT# if self . dry_run : #NEWLINE# #INDENT# return [ ] #NEWLINE# #UNINDENT# get_logger ( ) . debug ( text_type ( ( 'execute "%s" with params "%s"' % ( sql , params ) ) ) ) #NEWLINE# try : #NEWLINE# #INDENT# cursor . execute ( sql , params ) #NEWLINE# #UNINDENT# except DatabaseError as e : #NEWLINE# #INDENT# if print_all_errors : #NEWLINE# #INDENT# self . _print_sql_error ( params , sql , params ) #NEWLINE# #UNINDENT# raise #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# return cursor . fetchall ( ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# return [ ]