Exemplo n.º 1
0
def save_salary_data2(data):
    db_session.bulk_insert_mappings(Salary, data)
    db_session.commit()
Exemplo n.º 2
0
            if record["scientific_name"] == species_id["scientific_name"]:
                scientific_name_id = species_id["id"]
                species_found = True
        for source in sources_id_dict:
            if record["alias"] == source["alias"]:
                source_id = source["id"]
                source_found = True

        if species_found == False:
            sp_n = record["scientific_name"]
            print(f'Вид не найден: {sp_n}')
        else:
            if source_found == False:
                al = record["alias"]
                print(f'Источник не найден: {al}')
            else:
                formed_record = {
                    "latitude": record["latitude"],
                    "longitude": record["longitude"],
                    "region": record["region"],
                    "year": record["year"],
                    "scientific_name_id": scientific_name_id,
                    "source_id": source_id
                }
                formated_records.append(formed_record)

db_session.bulk_insert_mappings(Herb_occurrence,
                                formated_records,
                                return_defaults=True)
db_session.commit()
    "genus": "Solanum",
    "status": "absent"
}, {
    "scientific_name": "Cuscuta spp.",
    "Full_name": "Повилики (Cuscuta spp.)",
    "genus": "Cuscuta",
    "status": "present"
}, {
    "scientific_name": "Cuscuta lehmaniana",
    "Full_name": "Повилика Лемана (Cuscuta lehmaniana Bunge).",
    "genus": "Cuscuta",
    "status": "present"
}]

db_session.bulk_insert_mappings(Herb_species,
                                plants_list,
                                return_defaults=True)
db_session.commit()

sources_list = [{
    "alias":
    "gbif",
    "full_name":
    "Глобальная информационная система о биоразнообразии (Global Biodiversity Information Facility)"
}, {
    "alias":
    "rsn",
    "full_name":
    "Федеральная служба по ветеринарному и фитосанитарному надзору (Россельхознадзор)"
}]