|
|
|
@ -1,4 +1,6 @@ |
|
|
|
|
from git import Repo |
|
|
|
|
|
|
|
|
|
from dspt_api.util.insert_api_to_db import db_conn, db_cursor |
|
|
|
|
from update.models import Release |
|
|
|
|
import os |
|
|
|
|
import shutil |
|
|
|
@ -29,6 +31,7 @@ class GitUtil: |
|
|
|
|
'user': settings.CONFIG[ENV]['DB']['USER'], |
|
|
|
|
'password': settings.CONFIG[ENV]['DB']['PASSWORD'], |
|
|
|
|
'port': 3309, |
|
|
|
|
'database': self.db_name, |
|
|
|
|
'connect_timeout': 5, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -110,6 +113,27 @@ class GitUtil: |
|
|
|
|
r = os.system(cmd) |
|
|
|
|
print('cine.sql写入结果', r) |
|
|
|
|
|
|
|
|
|
def del_func_view(self): |
|
|
|
|
cmd_list = [ |
|
|
|
|
f'DROP FUNCTION IF EXISTS `{self.db_name}`.`GetCostAverage`;', |
|
|
|
|
f'DROP FUNCTION IF EXISTS `{self.db_name}`.`GetGoodsCount`;', |
|
|
|
|
f'DROP FUNCTION IF EXISTS `{self.db_name}`.`GetSumIn`;', |
|
|
|
|
f'DROP FUNCTION IF EXISTS `{self.db_name}`.`GetCostFifo`;', |
|
|
|
|
f'DROP FUNCTION IF EXISTS `{self.db_name}`.`GetSumOut`;', |
|
|
|
|
f'DROP FUNCTION IF EXISTS `{self.db_name}`.`GetCost`;', |
|
|
|
|
f'DROP FUNCTION IF EXISTS `{self.db_name}`.`GetGoodsPrice`;', |
|
|
|
|
f'DROP FUNCTION IF EXISTS `{self.db_name}`.`GetCostMobile`;', |
|
|
|
|
f'DROP VIEW IF EXISTS `{self.db_name}`.`retail_inventory_list`;' |
|
|
|
|
] |
|
|
|
|
_db_conn = pymysql.connect(**self.db_config) |
|
|
|
|
_db_cursor = db_conn.cursor() |
|
|
|
|
_db_cursor.execute() |
|
|
|
|
for cmd in cmd_list: |
|
|
|
|
_db_cursor.execute(cmd) |
|
|
|
|
_db_conn.commit() |
|
|
|
|
_db_cursor.close() |
|
|
|
|
_db_conn.close() |
|
|
|
|
|
|
|
|
|
# 获取数据库名称 |
|
|
|
|
def get_db_name(self, _release=''): |
|
|
|
|
if _release == '': |
|
|
|
|