Example #1
0
def main():
    # Parse command line
    import argparse
    parser = argparse.ArgumentParser(description='Add words to the SketchWithUs database')
    parser.add_argument('input', help='file containing one word per line')
    args = parser.parse_args()

    # Connect to the database
    db.connect()

    # Insert all the words
    with db.transaction():
        for chunk in _grouper(1000, _file_iter(args.input)):
            print chunk
            Word.insert_many({'text': x, 'plays': 0, 'wins': 0} for x in chunk).execute()