未提供项目说明
mongotransactions的Python项目详细描述
mongotransactions公司
包装mongoDB事务和其他pymongo操作
基本命令
frommongotransactionsimportDatabasedatabase=Database('mongodb+srv://username:password@host')# by default the class will use the first database the uri has access to you can change it withdatabase.set_database('db_name')# grab a collectionmy_collection=database.get_collection('my_collection')# then you can do your normal operationsfordocinmy_collection.find():print(doc)first=my_collection.find_one()# a list of collections is avalilble print(database.list_collections())# ['my_collection']
交易
包还包含一个围绕mongo事务和bulkwrite的包装器,以便 要批写入的多个集合中的多个保存/更新/删除 如果任何一个操作失败,它都将回滚到服务器。在
在MongoDB 4.2及更早版本中,您不能在事务中创建集合。在
该类采用上面的数据库类示例
^{pr2}$- 项目
标签: