Пример #1
0
    try:
        #Getting Connection from MongoDB
        conn = MongoClient('mongodb://localhost:27017/')

        #Creating a New DB in MongoDB
        print "Creating database in MongoDB named as " + DATABASE_NAME
        database   = conn[DATABASE_NAME]

        #Creating a collection named businessCollection in MongoDB
        print "Creating a collection in " + DATABASE_NAME + " named as " + COLLECTION_NAME
        collection = database[COLLECTION_NAME]

        #Loading BusinessCollection from a json file to MongoDB
        print "Loading testData.json file in the " + COLLECTION_NAME + " present inside " + DATABASE_NAME
        loadBusinessTable("testData.json", collection)
    
        #Finding All Business name and address(full_address, city and state) present in CITY_TO_SEARCH
        print "Executing FindBusinessBasedOnCity function"
        Interface.FindBusinessBasedOnCity(CITY_TO_SEARCH, SAVE_LOCATION_1, collection)

        #Finding All Business name and address(full_address, city and state) present in radius of MY_LOCATION for CATEGORIES_TO_SEARCH
        print "Executing FindBusinessBasedOnLocation function"
        Interface.FindBusinessBasedOnLocation(CATEGORIES_TO_SEARCH, MY_LOCATION, MAX_DISTANCE, SAVE_LOCATION_2, collection)

        #Delete database
        deleteDB(conn, DATABASE_NAME)
        conn.close()

    except Exception as detail:
        traceback.print_exc()