[Add]MainEngine增加dbDelete功能

This commit is contained in:
vn.py 2018-06-09 22:03:10 +08:00
parent 19f559f36a
commit b92eea8978
3 changed files with 15 additions and 3 deletions

View File

@ -137,3 +137,4 @@ DATABASE_CONNECTING_FAILED = u'MongoDB连接失败'
DATA_INSERT_FAILED = u'数据插入失败MongoDB没有连接'
DATA_QUERY_FAILED = u'数据查询失败MongoDB没有连接'
DATA_UPDATE_FAILED = u'数据更新失败MongoDB没有连接'
DATA_DELETE_FAILED = u'数据删除失败MongoDB没有连接'

View File

@ -137,4 +137,5 @@ DATABASE_CONNECTING_COMPLETED = u'MongoDB is connected.'
DATABASE_CONNECTING_FAILED = u'Failed to connect to MongoDB.'
DATA_INSERT_FAILED = u'Data insert failedplease connect MongoDB first.'
DATA_QUERY_FAILED = u'Data query failed, please connect MongoDB first.'
DATA_UPDATE_FAILED = u'Data update failed, please connect MongoDB first.'
DATA_UPDATE_FAILED = u'Data update failed, please connect MongoDB first.'
DATA_DELETE_FAILED = u'Data delete failed, please connect MongoDB first.'

View File

@ -251,7 +251,17 @@ class MainEngine(object):
collection = db[collectionName]
collection.replace_one(flt, d, upsert)
else:
self.writeLog(text.DATA_UPDATE_FAILED)
self.writeLog(text.DATA_UPDATE_FAILED)
#----------------------------------------------------------------------
def dbDelete(self, dbName, collectionName, flt):
"""从数据库中删除数据flt是过滤条件"""
if self.dbClient:
db = self.dbClient[dbName]
collection = db[collectionName]
collection.delete_one(flt)
else:
self.writeLog(text.DATA_DELETE_FAILED)
#----------------------------------------------------------------------
def dbLogging(self, event):
@ -735,7 +745,7 @@ class LogEngine(object):
function = self.levelFunctionDict[log.logLevel] # 获取日志级别对应的处理函数
msg = '\t'.join([log.gatewayName, log.logContent])
function(msg)
########################################################################
class PositionDetail(object):