def persist_download_history_and_app_info():
    # persist data into 2 tables
    # user_download_history - (user_id, download_history)
    # app_info              - (app_id, app_name)

    # clean up to remove all old data
    DataService.clean_up()

    # persist work done here
    DataService.read_then_persist('data/sample.data')

    # print for testing, comment out anything below within try block if you want

    # print db and collections, they will show only if any data was persisted
    print "dbs: " + str(DataService.client.database_names())
    db = DataService.db
    print "collections: " + str(db.collection_names()) + "\n"

    # print user_download_history
    user_download_history_cursor = DataService.get_cursor_user_download_history()
    print "user_download_history: count=" + str(user_download_history_cursor.count())
    for user_download_history in user_download_history_cursor:
        print "  " + str(user_download_history)
    print ""

    # print app_info
    app_info_cursor = DataService.get_cursor_app_info()
    print "app_info: count=" + str(app_info_cursor.count())
    for app_info in app_info_cursor:
        print "  " + str(app_info)
    print ""
Пример #2
0
def persist_download_history_and_app_info():
    # persist data into 2 tables
    # user_download_history - (user_id, download_history)
    # app_info              - (app_id, app_name)

    # clean up to remove all old data
    DataService.clean_up()

    # persist work done here
    DataService.read_then_persist('data/sample.data')

    # print for testing, comment out anything below within try block if you want

    # print db and collections, they will show only if any data was persisted
    print "dbs: " + str(DataService.client.database_names())
    db = DataService.db
    print "collections: " + str(db.collection_names()) + "\n"

    # print user_download_history
    user_download_history_cursor = DataService.get_cursor_user_download_history(
    )
    print "user_download_history: count=" + str(
        user_download_history_cursor.count())
    for user_download_history in user_download_history_cursor:
        print "  " + str(user_download_history)
    print ""

    # print app_info
    app_info_cursor = DataService.get_cursor_app_info()
    print "app_info: count=" + str(app_info_cursor.count())
    for app_info in app_info_cursor:
        print "  " + str(app_info)
    print ""