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.
- {cppackage-0.2.5 → cppackage-0.2.8}/CPpackage/db/sql_model.py +13 -7
- {cppackage-0.2.5 → cppackage-0.2.8}/CPpackage.egg-info/PKG-INFO +1 -1
- {cppackage-0.2.5 → cppackage-0.2.8}/PKG-INFO +1 -1
- {cppackage-0.2.5 → cppackage-0.2.8}/setup.py +1 -1
- {cppackage-0.2.5 → cppackage-0.2.8}/CPpackage/__init__.py +0 -0
- {cppackage-0.2.5 → cppackage-0.2.8}/CPpackage/core/__init__.py +0 -0
- {cppackage-0.2.5 → cppackage-0.2.8}/CPpackage/db/__init__.py +0 -0
- {cppackage-0.2.5 → cppackage-0.2.8}/CPpackage/db/config.py +0 -0
- {cppackage-0.2.5 → cppackage-0.2.8}/CPpackage/utils/__init__.py +0 -0
- {cppackage-0.2.5 → cppackage-0.2.8}/CPpackage.egg-info/SOURCES.txt +0 -0
- {cppackage-0.2.5 → cppackage-0.2.8}/CPpackage.egg-info/dependency_links.txt +0 -0
- {cppackage-0.2.5 → cppackage-0.2.8}/CPpackage.egg-info/entry_points.txt +0 -0
- {cppackage-0.2.5 → cppackage-0.2.8}/CPpackage.egg-info/not-zip-safe +0 -0
- {cppackage-0.2.5 → cppackage-0.2.8}/CPpackage.egg-info/requires.txt +0 -0
- {cppackage-0.2.5 → cppackage-0.2.8}/CPpackage.egg-info/top_level.txt +0 -0
- {cppackage-0.2.5 → cppackage-0.2.8}/LICENSE +0 -0
- {cppackage-0.2.5 → cppackage-0.2.8}/MANIFEST.in +0 -0
- {cppackage-0.2.5 → cppackage-0.2.8}/readme.md +0 -0
- {cppackage-0.2.5 → cppackage-0.2.8}/setup.cfg +0 -0
|
@@ -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
|
-
|
|
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(
|
|
115
|
-
|
|
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()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|