Skip to content

Commit

Permalink
goInception的mysql客户端调整为MySQLdb
Browse files Browse the repository at this point in the history
降低mysqlclient版本,解决Inception审核信息乱码的问题
版本提升为v1.6.5
  • Loading branch information
hhyo committed Jul 6, 2019
1 parent 0e6163a commit 08a285b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion common/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ <h4 class="modal-title" id="myModalLabel">

<!--底部部分 -->
<div class="row clearfix user-bottom-div">
<p><strong>SQL审核平台</strong>&nbsp;(v1.6.4)</p>
<p><strong>SQL审核平台</strong>&nbsp;(v1.6.5)</p>
</div>
<!-- jQuery (Bootstrap JavaScript 插件需要引入 jQuery务必先引入jquery js再引入bootstrap js) -->
<script src="{% static 'jquery/jquery.min.js' %}"></script>
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Django==2.0.13
mysqlclient==1.4.2.post1
mysqlclient==1.3.13
pymysql==0.9.3
requests==2.21.0
simplejson==3.16.0
Expand Down
6 changes: 3 additions & 3 deletions sql/engines/goinception.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import re
import traceback
import pymysql
import MySQLdb

from common.config import SysConfig
from sql.utils.sql_utils import get_syntax_type
Expand All @@ -17,12 +17,12 @@ def get_connection(self, db_name=None):
if self.conn:
return self.conn
if hasattr(self, 'instance'):
self.conn = pymysql.connect(host=self.host, port=self.port, charset=self.instance.charset or 'utf8mb4')
self.conn = MySQLdb.connect(host=self.host, port=self.port, charset=self.instance.charset or 'utf8mb4')
return self.conn
archer_config = SysConfig()
go_inception_host = archer_config.get('go_inception_host')
go_inception_port = int(archer_config.get('go_inception_port', 4000))
self.conn = pymysql.connect(host=go_inception_host, port=go_inception_port, charset='utf8mb4')
self.conn = MySQLdb.connect(host=go_inception_host, port=go_inception_port, charset='utf8mb4')
return self.conn

def execute_check(self, instance=None, db_name=None, sql=''):
Expand Down
14 changes: 7 additions & 7 deletions sql/engines/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ def tearDown(self):
SqlWorkflow.objects.all().delete()
SqlWorkflowContent.objects.all().delete()

@patch('pymysql.connect')
@patch('MySQLdb.connect')
def test_get_connection(self, _connect):
new_engine = GoInceptionEngine()
new_engine.get_connection()
Expand Down Expand Up @@ -1019,18 +1019,18 @@ def test_execute_finish(self, _query):
execute_result = new_engine.execute(workflow=self.wf)
self.assertIsInstance(execute_result, ReviewSet)

@patch('pymysql.connect.cursor.execute')
@patch('pymysql.connect.cursor')
@patch('pymysql.connect')
@patch('MySQLdb.connect.cursor.execute')
@patch('MySQLdb.connect.cursor')
@patch('MySQLdb.connect')
def test_query(self, _conn, _cursor, _execute):
_conn.return_value.cursor.return_value.fetchall.return_value = [(1,)]
new_engine = GoInceptionEngine()
query_result = new_engine.query(db_name=0, sql='select 1', limit_num=100)
self.assertIsInstance(query_result, ResultSet)

@patch('pymysql.connect.cursor.execute')
@patch('pymysql.connect.cursor')
@patch('pymysql.connect')
@patch('MySQLdb.connect.cursor.execute')
@patch('MySQLdb.connect.cursor')
@patch('MySQLdb.connect')
def test_query_not_limit(self, _conn, _cursor, _execute):
_conn.return_value.cursor.return_value.fetchall.return_value = [(1,)]
new_engine = GoInceptionEngine(instance=self.ins)
Expand Down
6 changes: 3 additions & 3 deletions src/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM docker.io/centos:7

ENV VERSION v1.6.4
ENV VERSION v1.6.5

WORKDIR /opt/archery

Expand All @@ -14,7 +14,7 @@ RUN yum -y install wget gcc make zlib-devel openssl openssl-devel ncurses-devel\
&& make && make install \
&& ln -fs /usr/local/python3/bin/python3 /usr/bin/python3 \
&& ln -fs /usr/local/python3/bin/pip3 /usr/bin/pip3 \
&& pip3 install virtualenv -i https://mirrors.ustc.edu.cn/pypi/web/simple/ \
&& pip3 install virtualenv \
&& cd /opt \
&& ln -fs /usr/local/python3/bin/virtualenv /usr/bin/virtualenv \
&& virtualenv venv4archery --python=python3 \
Expand Down Expand Up @@ -71,7 +71,7 @@ RUN cd /opt \
&& yum -y install openldap-devel gettext nginx \
&& git clone https://github.com/hhyo/archery.git && cd archery && git checkout $VERSION \
&& source /opt/venv4archery/bin/activate \
&& pip3 install -r /opt/archery/requirements.txt -i https://mirrors.ustc.edu.cn/pypi/web/simple/ \
&& pip3 install -r /opt/archery/requirements.txt \
&& cp /opt/archery/src/docker/nginx.conf /etc/nginx/ \
&& mv /opt/sqladvisor /opt/archery/src/plugins/ \
&& mv /opt/soar /opt/archery/src/plugins/ \
Expand Down

0 comments on commit 08a285b

Please sign in to comment.