#NEWLINE# def __query( self , query_string , instance = None ) : #NEWLINE# #INDENT# with self . mysqldb ( instance = instance ) as client : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# LOG . debug ( ( 'query_string: %s' % query_string ) ) #NEWLINE# client . query ( query_string ) #NEWLINE# r = client . store_result ( ) #NEWLINE# if ( r is not None ) : #NEWLINE# #INDENT# return r . fetch_row ( maxrows = 0 , how = 1 ) #NEWLINE# #UNINDENT# #UNINDENT# except _mysql_exceptions . ProgrammingError as e : #NEWLINE# #INDENT# LOG . error ( ( '__query ProgrammingError: %s' % e ) ) #NEWLINE# if ( e . args [ 0 ] == ER_DB_CREATE_EXISTS ) : #NEWLINE# #INDENT# raise DatabaseAlreadyExists ( e . args [ 1 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise GenericDriverError ( e . args ) #NEWLINE# #UNINDENT# #UNINDENT# except _mysql_exceptions . OperationalError as e : #NEWLINE# #INDENT# LOG . error ( ( '__query OperationalError: %s' % e ) ) #NEWLINE# if ( e . args [ 0 ] == ER_DB_DROP_EXISTS ) : #NEWLINE# #INDENT# raise DatabaseDoesNotExist ( e . args [ 1 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( e . args [ 0 ] == ER_CANNOT_USER ) : #NEWLINE# #INDENT# raise InvalidCredential ( e . args [ 1 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( e . args [ 0 ] == ER_WRONG_STRING_LENGTH ) : #NEWLINE# #INDENT# raise InvalidCredential ( e . args [ 1 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise GenericDriverError ( e . args ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# GenericDriverError ( e . args )