Пример #1
0
    def get(debug=False, **filters):
        query_string = "select * from Promotion"

        filters = {key: val for key, val in filters.iteritems() if val != None}

        i = 0
        for field in filters:
            if type(filters[field]) == bool:
                field_value = str(filters[field])
            else:
                field_value = "'{}'".format(filters[field])

            if i == 0:
                query_string += " where "

            if i < len(filters) - 1:
                query_string += "{}={} and ".format(field, field_value)
            else:
                query_string += "{}={}".format(field, field_value)
            i += 1

        response = utils.fetch_gql(query_string)
        if debug:
            logging.error("Query String: %s\n\n Response Length: %s" %
                          (query_string, len(response)))

        return response
Пример #2
0
    def get(self, debug=False, **filters):
        query_string = "select * from OpenXCStats"

        filters = {key: val for key, val in filters.iteritems() if val != None}

        i = 0
        for field in filters:
            if i == 0:
                query_string += " where "

            if i < len(filters) - 1:
                query_string += "%s='%s' and " % (field, filters[field])
            else:
                query_string += "%s='%s'" % (field, filters[field])
            i += 1

        response = utils.fetch_gql(query_string)
        if debug:
            logging.error("Query String: %s\n\n Response Length: %s" % (query_string, len(response)))

        return response
Пример #3
0
    def read(debug=False, **filters):
        query_string = "SELECT * FROM SourceInfo"

        filters = {key: val for key, val in filters.iteritems() if val != None}

        i = 0
        for field in filters:
            if i == 0:
                query_string += " where "

            if i < len(filters) - 1:
                query_string += "%s='%s' and " % (field, filters[field])
            else:
                query_string += "%s='%s'" % (field, filters[field])
            i += 1

        response = utils.fetch_gql(query_string)
        if debug:
            logging.error("Query String: %s\n\n Response Length: %s" %
                          (query_string, len(response)))

        return response