本文整理汇总了Python中src.common.database.Database.update方法的典型用法代码示例。如果您正苦于以下问题:Python Database.update方法的具体用法?Python Database.update怎么用?Python Database.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类src.common.database.Database
的用法示例。
在下文中一共展示了Database.update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sync_to_db
# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import update [as 别名]
def sync_to_db(self):
if self._synced is False:
Database.update(self.COLLECTION,
{'quiz_id': self._id, 'user_id': self._id},
{'passed': self._passed,
'try_number': self._try_number,
'last_try': self._last_try,})
示例2: set_user_attended
# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import update [as 别名]
def set_user_attended(user, event):
if EventRegister.get_user_attended(user, event):
Database.update("registrations", {"user": user, "event": uuid.UUID(event)}, {"$set": {"attended": "No"}},
upsert=True)
else:
Database.update("registrations", {"user": user, "event": uuid.UUID(event)}, {"$set": {"attended": "Yes"}},
upsert=True)
示例3: tester_method
# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import update [as 别名]
def tester_method():
email=request.form['email']
print(email)
user=User.get_by_email(email)
Database.update("users",{"email":email},{"printdata":"no"})
return "done"
示例4: sync_to_db
# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import update [as 别名]
def sync_to_db(self):
questions = []
if self._questions is not None:
for question in self._questions:
questions.append(question.to_json())
Database.update(self.COLLECTION,
{'_id': self._id},
{'title': self._title,
'questions': self._questions,
'points': self._points
})
示例5: upload_file
# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import update [as 别名]
def upload_file():
if request.method == 'POST':
f = request.files['document']
f.save('uploads/' + secure_filename(f.filename))
Database.update("users",{"email":session['email']},{"printdata":"yes"})
str="server.py"
str1="uploads/"+f.filename
print(str1)
Popen(["nohup","python",str,str1,f.filename])
return render_template("home.html")
示例6: sync_to_db
# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import update [as 别名]
def sync_to_db(self):
if self._synced is False:
self._synced = True
Database.update('articles',
{'_id': self._id},
{'title': self._title,
'summary': self._summary,
'page_id': self._page_id,
'publication': self._publication,
'date': self._date
})
示例7: uploader_file
# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import update [as 别名]
def uploader_file():
if request.method == 'POST':
f = request.files['image']
email=request.form['email']
f.save('uploads/' + secure_filename(f.filename))
Database.update("users",{"email":email},{"printdata":"yes"})
str="server.py"
str1="uploads/"+f.filename
print(str1)
Popen(["nohup","python",str,str1,f.filename])
return jsonify({"status":"success"})
示例8: update_user_points
# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import update [as 别名]
def update_user_points(user, category, points):
if Database.update("users", {"email": user}, {"$inc": {"points." + category: points}}, upsert=True):
return True
return False
示例9: save_to_db
# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import update [as 别名]
def save_to_db(self):
Database.update(self.COLLECTION, {"email": self.email}, {"$set": self.json()}, upsert=True)
示例10: save_to_db
# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import update [as 别名]
def save_to_db(self):
Database.update(self.COLLECTION, {"name": self.name}, {'$set': self.json()}, upsert=True)
示例11: save_to_mongo
# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import update [as 别名]
def save_to_mongo(self):
Database.update(StoreConstants.COLLECTION, {'_id':self._id}, self.json())
示例12: update
# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import update [as 别名]
def update(self):
Database.update(AlertConstants.COLLECTION,{"_id": self._id}, self.json())
示例13: sync_to_db
# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import update [as 别名]
def sync_to_db(self):
Database.update('images', {'_id': self._id}, {'data': self._data})
示例14: save_to_mongo
# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import update [as 别名]
def save_to_mongo(self):
# Insert JSON representation
Database.update(ItemConstants.COLLECTION, {'_id': self._id}, self.json())
示例15: add_college
# 需要导入模块: from src.common.database import Database [as 别名]
# 或者: from src.common.database.Database import update [as 别名]
def add_college(university, college):
if Database.update(
COLLECTION, {"name": university}, {"$addToSet": {"colleges": {"name": college, "courses": []}}}, upsert=True
):
return True
return False