-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
数据库管理页面-添加mysql/pgsql/mongo实例选择下拉菜单-并添加pgsql/mongo创建数据库功能 #1401
base: master
Are you sure you want to change the base?
Conversation
有冲突,解决下,另外mongo 的修改和pr无关,删掉或者另开一个pr吧 |
78c7fba
to
b8eabf9
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1401 +/- ##
==========================================
- Coverage 77.95% 74.56% -3.39%
==========================================
Files 76 82 +6
Lines 11963 13275 +1312
==========================================
+ Hits 9326 9899 +573
- Misses 2637 3376 +739 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感谢你提交的变更,如果能够将获取数据库相关方法抽象到engine中,那就更合适了,可参考#1402
sql/templates/database.html
Outdated
<select id="db_type1" class="form-control selectpicker" name="db_type" | ||
title="db_type" | ||
data-live-search="true"> | ||
<option value="" selected="selected">db_type</option> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
和实例列表统一,叫实例类型吧
sql/engines/mongo.py
Outdated
result['msg'] += f"\n错误: {collection_name} 文档不存在!" | ||
sql = sql.strip() | ||
# 以;作为语句结束 | ||
q_sql = sql.split(";") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用sqlparse.split是不是更合适?
@@ -320,13 +320,18 @@ def execute_workflow(self, workflow): | |||
"""执行上线单,返回Review set""" | |||
return self.execute(db_name=workflow.db_name, sql=workflow.sqlworkflowcontent.sql_content) | |||
|
|||
def execute(self, db_name=None, sql=''): | |||
def execute(self, db_name=None, sql='', ddl=''): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没有看出来ddl和非ddl的区别,可以去除ddl入参和下面的判断
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mongo.py ddl执行用的还是之前的方法,确实没有区别可以去掉,是为了打印ddl字符串加了一个判断。
@@ -299,6 +300,34 @@ def execute_workflow(self, workflow, close_conn=True): | |||
self.close() | |||
return execute_result | |||
|
|||
def execute(self, db_name=None, sql='', ddl='', close_conn=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
execute方法就是用于执行有影响的语句,可以去除ddl入参和判断,统一设置autocommit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pgsql执行create database需要设置conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)自动提交,和dml操作默认放到一个block事务提交有冲突,dml保证事务一致性还是比较合理。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是否是ddl直接在方法内判断比较好,可以优化一下
@@ -23,14 +23,15 @@ | |||
@permission_required('sql.menu_database', raise_exception=True) | |||
def databases(request): | |||
"""获取实例数据库列表""" | |||
db_type1 = request.POST.get('db_type1') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
通过instance_id获取实例对象后就可以判断db类型了,不需要外部再传入这个参数
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯看了源代码instance_id获取实例可以得到db_type,不过前端传的db_type1是为了在选择数据类型后在自动过滤该db_type1的实例列表,和返回db_type没有关系吧。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个方法是获取实例的数据库列表,看了下不需要这个
@@ -3,6 +3,15 @@ | |||
{% block content %} | |||
<!-- 自定义操作按钮--> | |||
<div id="toolbar" class="form-inline pull-left"> | |||
<div class="form-group"> | |||
<select id="db_type1" class="form-control selectpicker" name="db_type" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
db_type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯,这个修改成db_type_f,表示数据库类型过滤
<div class="col-sm-9"> | ||
<input type="text" id="remark" class="form-control" | ||
autocomplete="off" | ||
placeholder="请输入备注"> | ||
placeholder="请输入备注/mongo密码"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不特意描述为密码比较好,这里就是填写描述信息的地方
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯,这个可以修改回来。
mongo create database ddl是自动创建用户和密码了,为了不修改模型层,所以复用了一个字段:)。
commits:数据库管理页面-添加pgsql实例选择下拉菜单-并添加pgsql创建数据库功