Example #1
0
def export(output_dir: str) -> None:
    """Export collections to csv."""

    mongo_client = Client()
    mongo_client.set_db()
    all_collections = mongo_client.collections()
    documents = mongo_client.fetch_documents(all_collections)
    df = mongo_client.convert_to_df(documents)
    mongo_client.export_to_csv(df, output_dir)
Example #2
0
def run(phrase: str) -> None:
    """Run scraper."""

    scrapper = Scrapper(phrase)
    scrapper.get_similar_words()
    scrapper.scrap_raw_data()

    mongo_client = Client()
    mongo_client.set_db()
    mongo_client.insert(data=scrapper.scrapped, collection=phrase)
    click.echo(f"{len(scrapper.scrapped)} records saved in database.")
Example #3
0
def show() -> None:
    """Show all collections."""

    mongo_client = Client()
    mongo_client.set_db()
    mongo_client.collections()
Example #4
0
def delete(collection_name: str) -> None:
    """Delete collection from DB."""

    mongo_client = Client()
    mongo_client.set_db()
    mongo_client.delete_collection(collection_name)