@name 添加到服务器
(self, find)
| 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 | """ |
no test coverage detected