cppackage 0.2.5__tar.gz → 0.2.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -103,24 +103,28 @@ def add_columns(table_name, database, columns):
103
103
  # 表结构校验
104
104
  def check_and_sync_columns(df ,table_name, database, max_new=5):
105
105
 
106
+ # df字段
106
107
  df_cols = set(df.columns)
107
- db_cols= get_table_columns(table_name, database)
108
+ # 数据库字段
109
+ db_cols = set(get_table_columns(table_name, database))
110
+ # 新增字段
108
111
  new_cols = df_cols - db_cols
112
+
113
+ # 缺失字段(减少的字段,不处理)
109
114
  missing_cols = db_cols - df_cols
110
115
  print("新增字段:", new_cols if new_cols else "无")
111
116
  print("缺失字段(忽略):", missing_cols if missing_cols else "无")
112
117
 
113
- # 超限
114
- if len(new_cols) > max_new:
115
- raise Exception(f"新增字段超过{max_new}个: {new_cols}")
116
-
118
+ # 最大新增字段限制
119
+ if len(db_cols) * 0.2 > max_new:
120
+ max_new = int(len(db_cols) *0.2)
117
121
  # 自动补
118
122
  if 0 < len(new_cols) <= max_new:
119
-
120
123
  print("开始同步字段...")
121
124
  add_columns(table_name, database, new_cols)
122
125
  print("字段同步成功")
123
-
126
+ else:
127
+ raise Exception(f"新增字段超过{max_new}个: {new_cols}")
124
128
  return True
125
129
 
126
130
 
@@ -158,6 +162,8 @@ def update_datas(df, table_name, database):
158
162
  print("入库失败:", e)
159
163
  if '1054, "Unknown column' in str(e):
160
164
  check_and_sync_columns(df,table_name,database)
165
+ else:
166
+ raise Exception(e)
161
167
  finally:
162
168
  if conn:
163
169
  conn.close()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cppackage
3
- Version: 0.2.5
3
+ Version: 0.2.8
4
4
  Summary: 超品集团自用的Python包
5
5
  Home-page: https://github.com/example/CPpackage
6
6
  Author: team-数智组
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cppackage
3
- Version: 0.2.5
3
+ Version: 0.2.8
4
4
  Summary: 超品集团自用的Python包
5
5
  Home-page: https://github.com/example/CPpackage
6
6
  Author: team-数智组
@@ -10,7 +10,7 @@ with open('readme.md', 'r', encoding='utf-8') as f:
10
10
  # 包的基本信息
11
11
  setup(
12
12
  name='cppackage',
13
- version='0.2.5',
13
+ version='0.2.8',
14
14
  description='超品集团自用的Python包',
15
15
  long_description=long_description,
16
16
  long_description_content_type='text/markdown',
File without changes
File without changes
File without changes
File without changes