def _exec_query(self, statement): ''' ************************************************************ Function : _exec_query Arguments : 1) statement (string) : SQL command Return : Description : Execute a query ************************************************************ ''' if self.unread_result is True: GBASELOGGER.error("Unread result found.") raise GBaseError.OperationalError("Unread result found.") GBASELOGGER.debug("Execute query. '%s'" % statement) self.query(statement)
def cursor(self): ''' ************************************************************ Function : cursor Arguments : Return : instance of GBaseCursor class Description : Returns a cursor object ************************************************************ ''' if not self.is_connected(): GBASELOGGER.error("GBase Connection not available.") raise GBaseError.OperationalError( "GBase Connection not available.") GBASELOGGER.debug("Return GBaseCursor object.") return GBaseCursor(self)
def query(self, statement): ''' ************************************************************ Function : query Arguments : 1) statement (string) : SQL command Return : dict Description : Execute a query and return result ************************************************************ ''' GBASELOGGER.debug("Send query packet. SQL: '%s'" % statement) GBASELOGGER.sql(statement) packet = self._send(ServerCmd.QUERY, statement) GBASELOGGER.debug("Handle result.") result = self._handle_result(packet) if self._have_next_result: GBASELOGGER.sql( 'Use query_iter for statements with multiple queries.') raise GBaseError.OperationalError( 'Use query_iter for statements with multiple queries.') return result