django-vue-admin/dvadmin-backend/apps/vadmin/scripts/__init__.py

15 lines
487 B
Python
Raw Normal View History

2021-02-27 10:22:21 +00:00
import os
def getSql(filename):
"""
获取文件内所有sql
:param filename: 例如os.path.join('permission','permission_dept.sql')
:return:
"""
2021-03-13 10:06:47 +00:00
abspath = os.path.abspath(os.path.join(os.path.abspath(os.path.dirname(__file__)), ".."))
pwd = os.path.join(abspath, 'scripts', filename)
2021-02-27 19:15:53 +00:00
with open(pwd,'rb') as fp:
content = fp.read().decode('utf8')
2021-03-10 16:26:47 +00:00
return [ele for ele in content.split('\n') if not ele.startswith('--') and ele.strip(' ')]