MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / SyncToDatabases

Method SyncToDatabases

class/databaseModel/sqlserverModel.py:281–306  ·  view source on GitHub ↗
(self, get)

Source from the content-addressed store, hash-verified

279
280 # 同步数据库到服务器
281 def SyncToDatabases(self, get):
282 type = int(get['type'])
283 n = 0
284 sql = public.M('databases')
285 if type == 0:
286 data = sql.field('id,name,username,password,accept,type,sid,db_type').where('type=?', ('SQLServer',)).select()
287
288 for value in data:
289 if value['db_type'] in ['1', 1]:
290 continue # 跳过远程数据库
291 result = self.ToDataBase(value)
292 if result == 1: n += 1
293 else:
294 import json
295 data = json.loads(get.ids)
296 for value in data:
297 find = sql.where("id=? AND LOWER(type)=LOWER('SQLServer')", (value,)).field('id,name,username,password,sid,db_type,accept,type').find()
298 result = self.ToDataBase(find)
299 if result == 1: n += 1
300
301 if n == 1:
302 return public.returnMsg(True, '同步成功')
303 elif n == 0:
304 return public.returnMsg(False, '同步失败')
305
306 return public.returnMsg(True, 'DATABASE_SYNC_SUCCESS', (str(n),))
307
308 # 添加到服务器
309 def ToDataBase(self, find):

Callers

nothing calls this directly

Calls 8

ToDataBaseMethod · 0.95
returnMsgMethod · 0.80
MMethod · 0.45
selectMethod · 0.45
whereMethod · 0.45
fieldMethod · 0.45
loadsMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected