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

Method SyncToDatabases

class/databaseModel/pgsqlModel.py:899–926  ·  view source on GitHub ↗

@name同步数据库到服务器

(self, get)

Source from the content-addressed store, hash-verified

897 return {'data': 5432, "status": False}
898
899 def SyncToDatabases(self, get):
900 """
901 @name同步数据库到服务器
902 """
903 tmp_type = int(get['type'])
904 n = 0
905 sql = public.M('databases')
906 if tmp_type == 0:
907 # data = sql.field('id,name,username,password,accept,type,sid,db_type').where('type=?',('pgsql',)).select()
908 data = sql.field('id,name,username,password,accept,type,sid,db_type').where("LOWER(type)=LOWER('PgSql')", ()).select()
909
910 for value in data:
911 if value['db_type'] in ['1', 1]:
912 continue # 跳过远程数据库
913 result = self.ToDataBase(value)
914 if result == 1: n += 1
915 else:
916 import json
917 data = json.loads(get.ids)
918 for value in data:
919 find = sql.where("id=?", (value,)).field('id,name,username,password,sid,db_type,accept,type').find()
920 result = self.ToDataBase(find)
921 if result == 1: n += 1
922 if n == 1:
923 return public.returnMsg(True, '同步成功')
924 elif n == 0:
925 return public.returnMsg(False, '同步失败')
926 return public.returnMsg(True, 'DATABASE_SYNC_SUCCESS', (str(n),))
927
928 def ToDataBase(self, find):
929 """

Callers 1

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