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

Method SyncGetDatabases

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

Source from the content-addressed store, hash-verified

325
326 # 从服务器获取数据库
327 def SyncGetDatabases(self, get):
328
329 n = 0
330 s = 0
331 db_type = 0
332 self.sid = get.get('sid/d', 0)
333 if self.sid: db_type = 2
334
335 mssql_obj = self.get_mssql_obj_by_sid(self.sid)
336
337 data = mssql_obj.query('SELECT name FROM MASTER.DBO.SYSDATABASES ORDER BY name')
338 isError = self.IsSqlError(data)
339 if isError != None: return isError
340 if type(data) == str: return public.returnMsg(False, data)
341
342 sql = public.M('databases')
343 nameArr = ['information_schema', 'performance_schema', 'mysql', 'sys', 'master', 'model', 'msdb', 'tempdb', 'ReportServerTempDB', 'YueMiao', 'ReportServer']
344 for item in data:
345 dbname = item[0]
346 if sql.where("name=? AND LOWER(type)=LOWER('SQLServer')", (dbname,)).count(): continue
347 if not dbname in nameArr:
348 if sql.table('databases').add('name,username,password,accept,ps,addtime,type,sid,db_type', (dbname, dbname, '', '', public.getMsg('INPUT_PS'), time.strftime('%Y-%m-%d %X', time.localtime()), 'SQLServer', self.sid, db_type)): n += 1
349
350 return public.returnMsg(True, 'DATABASE_GET_SUCCESS', (str(n),))
351
352 def ResDatabasePassword(self, args):
353 """

Callers

nothing calls this directly

Calls 10

get_mssql_obj_by_sidMethod · 0.95
returnMsgMethod · 0.80
getMethod · 0.45
queryMethod · 0.45
IsSqlErrorMethod · 0.45
MMethod · 0.45
countMethod · 0.45
whereMethod · 0.45
addMethod · 0.45
tableMethod · 0.45

Tested by

no test coverage detected