Skip to content

Commit

Permalink
修复代码规范问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Maple-mxf committed Jan 12, 2022
1 parent 477f5d4 commit 4d0d50d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

# 是否开启debug模式
debug = True
DEBUG = True

# 读取数据库环境变量
username = os.environ.get("MYSQL_USERNAME", 'root')
Expand Down
2 changes: 1 addition & 1 deletion wxcloudrun/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# 初始化web应用
app = Flask(__name__, instance_relative_config=True)
app.config['DEBUG'] = config.debug
app.config['DEBUG'] = config.DEBUG

# 设定数据库链接
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://{}:{}@{}/flask_demo'.format(config.username, config.password,
Expand Down
10 changes: 6 additions & 4 deletions wxcloudrun/dao.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import logging

from sqlalchemy.exc import OperationalError

from wxcloudrun import db
from wxcloudrun.model import Counters

Expand All @@ -15,7 +17,7 @@ def query_counterbyid(id):
"""
try:
return Counters.query.filter(Counters.id == id).first()
except BaseException as e:
except OperationalError as e:
logger.info("query_counterbyid errorMsg= {} ".format(e))
return None

Expand All @@ -31,7 +33,7 @@ def delete_counterbyid(id):
return
db.session.delete(counter)
db.session.commit()
except BaseException as e:
except OperationalError as e:
logger.info("delete_counterbyid errorMsg= {} ".format(e))


Expand All @@ -43,7 +45,7 @@ def insert_counter(counter):
try:
db.session.add(counter)
db.session.commit()
except BaseException as e:
except OperationalError as e:
logger.info("insert_counter errorMsg= {} ".format(e))


Expand All @@ -58,5 +60,5 @@ def update_counterbyid(counter):
return
db.session.flush()
db.session.commit()
except BaseException as e:
except OperationalError as e:
logger.info("update_counterbyid errorMsg= {} ".format(e))
4 changes: 2 additions & 2 deletions wxcloudrun/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ def make_succ_response(data):
return Response(data, mimetype='application/json')


def make_err_response(errorMsg):
data = json.dumps({'code': -1, 'errorMsg': errorMsg})
def make_err_response(err_msg):
data = json.dumps({'code': -1, 'errorMsg': err_msg})
return Response(data, mimetype='application/json')

0 comments on commit 4d0d50d

Please sign in to comment.