示例#1
0
def new_connection():
    from example.model import User, Photo
    db_prefix = ''
    connection = SingleDbConnection(os.environ['MONGO_DB_NAME'], db_prefix,
                                    os.environ['MONGO_URI'])
    connection.register(User)
    connection.register(Photo)
    connection.generate_index(User)
    connection.generate_index(Photo)
    return connection
示例#2
0
文件: __init__.py 项目: hadrien/velo
def remove_test_database():
    from pyramid_mongokit import SingleDbConnection
    connection = SingleDbConnection(os.environ['MONGO_DB_NAME'], '',
                                    os.environ['MONGO_URI'])
    connection.drop_database(os.environ['MONGO_DB_NAME'])