forked from msooner/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTool.py
More file actions
44 lines (35 loc) · 1.36 KB
/
Tool.py
File metadata and controls
44 lines (35 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#-*-coding:utf-8-*-
from library.Handlers import BaseHandler
from service.ToolService import ToolService
from library.Exception import CustomException
from library.Route import route
from library.Decorate import Return
@route(r'/tool/dbs')
class AllDbHandler(BaseHandler):
@Return
def get(self, *args, **kwargs):
""" 所有数据库 """
return ToolService().get_all_db()
@route(r'/tool/tables')
class AllTablesHandler(BaseHandler):
@Return
def get(self, *args, **kwargs):
""" 所有表 """
dbname = self.get_argument('dbname', None)
if not dbname:
raise CustomException(code=10001, desc="请选择要操作的数据库")
return ToolService().get_all_tables(dbname)
@route(r'/tool/schema')
class GetSchemaHandler(BaseHandler):
@Return
def get(self, *args, **kwargs):
""" 获取模式 """
dbname = self.get_argument("dbname", None)
table = self.get_argument("table", None)
superclass = self.get_argument("superclass", None)
prefix = self.get_argument("prefix", "yes")
if not dbname:
raise CustomException(code=10001, desc="请选择要操作的数据库")
if not table:
raise CustomException(code=10001, desc="请选择要操作的数据表")
return ToolService().get_schema(dbname, table, superclass, prefix)