コード例 #1
0
    def get_filtered_plants(self, species, dec_or_evg):

        print("species is", len(species))
        print("doe is", len(dec_or_evg))

        if len(species) == 0 and len(dec_or_evg) == 0:
            print("not filtering")
            return self.get_all_plants()

        cursor = self._connection.cursor()

        print("filtering")

        stmtStr, vals = self.create_filter_stmt(species, dec_or_evg)

        cursor.execute(stmtStr, vals)

        plants = []
        row = cursor.fetchone()
        while row is not None:
            plant = Plant(str(row[0]), str(row[1]), str(row[2]), str(row[3]),
                          str(row[4]))
            plant = Plant.getDict(plant)

            plants.append(plant)
            row = cursor.fetchone()
        cursor.close()
        return plants
コード例 #2
0
    def get_plant_by_id(self, id_num):
        cursor = self._connection.cursor()
        stmt = "SELECT * FROM plant_indiv WHERE primary_id = %s;"
        cursor.execute(stmt, [id_num])

        row = cursor.fetchone()
        if row is not None:
            plant = Plant(str(row[0]), str(row[1]), str(row[2]), str(row[3]),
                          str(row[4]))
            plant = Plant.getDict(plant)
        cursor.close()
        return plant
コード例 #3
0
    def get_all_plants(self):
        cursor = self._connection.cursor()
        stmt = "SELECT * FROM plant_indiv;"
        cursor.execute(stmt)

        plants = []
        row = cursor.fetchone()
        while row is not None:
            plant = Plant(str(row[0]), str(row[1]), str(row[2]), str(row[3]),
                          str(row[4]))
            plant = Plant.getDict(plant)
            plants.append(plant)
            row = cursor.fetchone()
        cursor.close()
        return plants
コード例 #4
0
    def search_in_range(self, south, north, east, west):
        cursor = self._connection.cursor()
        stmt, values = self.create_range_stmt(south, north, east, west)
        cursor.execute(stmt, values)

        plants = []
        row = cursor.fetchone()
        while row is not None:
            plant = Plant(str(row[0]), str(row[1]), str(row[2]), str(row[3]),
                          str(row[4]))
            plant = Plant.getDict(plant)
            plants.append(plant)
            row = cursor.fetchone()
        cursor.close()
        return plants