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

Method ToDataBase

class/databaseModel/pgsqlModel.py:928–950  ·  view source on GitHub ↗

@name 添加到服务器

(self, find)

Source from the content-addressed store, hash-verified

926 return public.returnMsg(True, 'DATABASE_SYNC_SUCCESS', (str(n),))
927
928 def ToDataBase(self, find):
929 """
930 @name 添加到服务器
931 """
932 if find['username'] == 'bt_default': return 0
933 if len(find['password']) < 3:
934 find['username'] = find['name']
935 find['password'] = public.md5(str(time.time()) + find['name'])[0:10]
936 public.M('databases').where("id=? AND LOWER(type)=LOWER('PgSql')", (find['id'],)).save('password,username', (find['password'], find['username']))
937
938 sid = find['sid']
939 pgsql_obj = self.get_sql_obj_by_sid(sid)
940 status, err_msg = pgsql_obj.connect()
941 if status is False:
942 return public.returnMsg(False, "连接数据库失败!")
943
944 result = pgsql_obj.execute("""CREATE DATABASE "{}";""".format(find['name']))
945 isError = self.IsSqlError(result)
946 if isError != None and isError['status'] == False and isError['msg'] == '指定数据库已存在,请勿重复添加.': return 1
947
948 self.__CreateUsers(sid, find['name'], find['username'], find['password'], '127.0.0.1')
949
950 return 1
951
952 def SyncGetDatabases(self, get):
953 """

Callers 1

SyncToDatabasesMethod · 0.95

Calls 12

get_sql_obj_by_sidMethod · 0.95
__CreateUsersMethod · 0.95
timeMethod · 0.80
returnMsgMethod · 0.80
md5Method · 0.45
saveMethod · 0.45
whereMethod · 0.45
MMethod · 0.45
connectMethod · 0.45
executeMethod · 0.45
formatMethod · 0.45
IsSqlErrorMethod · 0.45

Tested by

no test coverage detected