feat: 支持从文件中读取官网数据库

This commit is contained in:
caoqianming 2024-05-11 14:21:06 +08:00
parent ebd49f5dc0
commit 3d3f2a971f
1 changed files with 40 additions and 37 deletions

View File

@ -111,7 +111,10 @@ def get_cbma_info_from_db_and_ana(year: str = '2023'):
df = pd.read_sql_query(query_gzhs, conn)
conn.close()
# 尝试连接官网库进行查询
file_path = os.path.join(BASE_DIR, f'cbma_site/{year}.xlsx')
if os.path.exists(file_path):
df_web = pd.read_excel(file_path, sheet_name='Result 1')
else:
import psycopg2
conn_web = None
df_web = None