提交 721c31d7 作者: LiuLiYuan

同步数据 05/29

上级 e699dcba
"""
"""
......@@ -2,12 +2,13 @@
同步正式环境企业表
"""
from datetime import datetime
import requests
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
from base.BaseCore import BaseCore
baseCore = BaseCore()
log = baseCore.getLogger()
# 144数据库
......@@ -64,7 +65,8 @@ if __name__ == "__main__":
com_code = info.split('|')[0]
com_name = info.split('|')[1]
com_english_name = info.split('|')[2]
result = search_formal_table('CompanyName, SocialCode, EnglishName, SecuritiesCode, SecuritiesShortName, Place, isIPO, SecuritiesType, Category, Exchange, countryName', 'EnterpriseInfo', 'SocialCode', com_code, cursor_)
result = search_formal_table('CompanyName, SocialCode, EnglishName, SecuritiesCode, SecuritiesShortName, Place, isIPO, SecuritiesType, Category, Exchange, countryName', 'EnterpriseInfo',
'SocialCode', com_code, cursor_)
u_name, u_code, u_ename, u_short_name, u_type, u_category, u_exchange = '', '', '', '', '', '', ''
# 更新语句
update_sql = """update EnterpriseInfo set {} where SocialCode = {}"""
......@@ -84,7 +86,8 @@ if __name__ == "__main__":
u_countryname = '中国内地'
fields += f'countryName = "{u_countryname}", '
if not result[0][3]:
result_ipo = search_formal_table('social_credit_code, securities_code, securities_short_name, securities_type, category,exchange', 'sys_base_enterprise_ipo', 'social_credit_code', com_code,cursor)
result_ipo = search_formal_table('social_credit_code, securities_code, securities_short_name, securities_type, category,exchange', 'sys_base_enterprise_ipo', 'social_credit_code',
com_code, cursor)
if result_ipo:
# 是上市企业
if not result[0][6]:
......@@ -117,10 +120,20 @@ if __name__ == "__main__":
log.info(f'更新的sql语句--{update_sql}')
update_table(update_sql, cursor_, cnx_)
else:
# 企业表中没有需要插入数据
pass
result_ipo = search_formal_table('social_credit_code, securities_code, securities_short_name, securities_type, category,exchange', 'sys_base_enterprise_ipo', 'social_credit_code',
com_code, cursor)
if result_ipo:
SecuritiesCode = result_ipo[1]
SecuritiesShortName = result_ipo[2]
securities_type = result_ipo[3]
Category = result_ipo[4]
exchange = result_ipo[5]
sqlInsert = 'insert into EnterpriseInfo(CompanyName, SocialCode, EnglishName, SecuritiesCode, SecuritiesShortName, Place, isIPO, SecuritiesType, Category, Exchange, countryName) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'
baseCore.cursor.execute(sqlInsert, (com_name, com_code, com_english_name, SecuritiesCode, 1, 1, securities_type, Category, exchange, '中国内地'))
baseCore.cnx.commit()
log.info(f'{com_name}==={com_name}===上市企业===插入成功')
else:
sqlInsert = 'insert into EnterpriseInfo(CompanyName, SocialCode, EnglishName, Place, isIPO, countryName) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'
baseCore.cursor.execute(sqlInsert, (com_name, com_code, com_english_name, 1, 1, '中国内地'))
baseCore.cnx.commit()
log.info(f'{com_name}==={com_name}===非上市企业===插入成功')
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论