コード例 #1
0
def list():
    clients = []
    curseur.execute("SELECT * FROM client")
    results = curseur.fetchall()
    for row in results:
        clients.append(Client(row[0], row[1], row[2], row[3]))
    return render_template('index.html', clients=clients)
コード例 #2
0
    def caTotal(self, villes=[]):

        if (len(villes) == 0):
            curseur.execute("SELECT ca FROM client")
            valeurs = curseur.fetchall()
            total = 0
            for v in valeurs:
                total = total + v[0]
            return "Le CA total est de %f €" % (total)
        else:
            qry = "SELECT ca FROM client"
            for ville in villes:
                curseur.execute(
                    "SELECT sum(ca) FROM client WHERE ville = '%s' GROUP BY ville"
                    % (ville))
                valeurs = curseur.fetchall()
                responses.append('Le CA total de %s est de %f' %
                                 (ville, valeurs[0][0]))
            return responses
コード例 #3
0
    def loadColumns(self):

        curseur.execute("SHOW COLUMNS FROM " + self.__table)

        if curseur.rowcount == 0 :
            return False

        columns = curseur.fetchall()
        for column in columns:
            self.__columns.append(column['Field'])
コード例 #4
0
def ca(ville):
    curseur.execute(
        "SELECT sum(ca) FROM client WHERE ville = '%s' GROUP BY ville" %
        (ville))
    valeurs = curseur.fetchall()
    return 'Le CA total de %s est de %f euros' % (ville, valeurs[0][0])
コード例 #5
0
        if len(where)>0:
            request += " WHERE " + " AND ".join(where)

        print request

        try:
            curseur.execute(request)

        except MySQLdb.Error, e:
            try:
                print ("MySQL Error [%d]: %s") % (e.args[0], e.args[1])
            except IndexError:
                print ("MySQL Error: %s") % str(e)
                raise Error(400,"Error occuring processing the request")

        rows = curseur.fetchall()

        if len(rows) == 0:
            raise Error(404,"Nothing found matching the request")

        result = []
        for row in rows:
            entity = Entity(self.__table)
            entity.id = row['id']
            entity.load()
            result.append(entity)

        return result

    def _getJoinClause(self,entity):
        joinClause = []