Пример #1
0
 def __init__(self, language):
     self.__db = get_database_connection()
     self.language = language
     self.headers = get_request_headers(self.base_url)
     self.latest_timestamp = self.get_latest_timestamp()
     self.existing_articles = self.get_existing_articles()
     self.existing_authors = self.get_existing_authors()
Пример #2
0
            logging.info(msg)

            insert_template = """INSERT INTO vernacularname("taxonomyId", "language", "name", "source") VALUES ({{ taxonomy_id}}, {{ lang_code }}, {{ name }}, {{ source }})"""
            execute_sql_from_jinja_string(conn,
                                          sql_string=insert_template,
                                          context={
                                              'taxonomy_id': taxonomy_id,
                                              'lang_code': lang_code,
                                              'name': name,
                                              'source': source
                                          })
            total_vernacularnames_counter += 1

    end_time = time.time()

    msg = f"Done loading {total_vernacularnames_counter} (for {total_taxa_counter} taxa) vernacular names in {round(end_time - start_time)}s."
    print(msg)
    logging.info(msg)


if __name__ == "__main__":
    connection = get_database_connection()
    config = get_config()
    setup_log_file("./logs/vernacular_names.log")
    # list of 2-letters language codes (ISO 639-1)
    languages = ['fr', 'nl', 'en']
    populate_vernacular_names(connection,
                              config_parser=config,
                              empty_only=False,
                              filter_lang=languages)