コード例 #1
0
ファイル: manage.py プロジェクト: mcgrathd/pillar
def clear_db():
    """Wipes the database
    """
    from pymongo import MongoClient

    client = MongoClient(MONGO_HOST, 27017)
    db = client.eve
    db.drop_collection('nodes')
    db.drop_collection('node_types')
    db.drop_collection('tokens')
    db.drop_collection('users')
コード例 #2
0
ファイル: manage.py プロジェクト: BibleUs/pillar
def clear_db():
    """Wipes the database
    """
    from pymongo import MongoClient

    client = MongoClient(MONGO_HOST, 27017)
    db = client.eve
    db.drop_collection('nodes')
    db.drop_collection('node_types')
    db.drop_collection('tokens')
    db.drop_collection('users')
コード例 #3
0
ファイル: lucky.py プロジェクト: vivelohoy/luckynumbers
            record = LuckyNumber(winning_number_record)

            if save_to_db:
                get_or_create(record.toJSON(), numbers_collection)

            if noisy:
                print record


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("-t", "--test", help="Run the doctests", action="store_true")
    parser.add_argument("-s", "--scrape", help="Scrape the lottery website", action="store_true")
    parser.add_argument(
        "-p",
        "--print_data",
        help="Print the scraped data in a csv format so that you can do python lucky.py -s -p > data.csv",
        action="store_true",
    )
    parser.add_argument("-sd", "--save_data", help="Save the scraped data to the MongoDB database", action="store_true")
    parser.add_argument(
        "-ddb", "--delete_db", help="Save the scraped data to the MongoDB database", action="store_true"
    )
    args = parser.parse_args()
    if args.test:
        doctest.testmod()
    if args.scrape:
        main_scrape(noisy=args.print_data, save_to_db=args.save_data)
    if args.delete_db:
        db.drop_collection(numbers_collection)
コード例 #4
0
ファイル: tests.py プロジェクト: mittmannv8/squid_handler
 def tearDown(self):
     db.drop_collection('log')