mdbq 0.1.7__py3-none-any.whl → 0.1.8__py3-none-any.whl
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.
mdbq/mysql/mysql.py
CHANGED
@@ -181,6 +181,8 @@ class MysqlUpload:
|
|
181
181
|
# 最优先处理 ID 类型, 在 mysql 里面, 有些列数字过长不能存储为 int 类型
|
182
182
|
if 'id' in col or 'ID' in col or 'Id' in col or '摘要' in col or '商家编码' in col or '单号' in col or '款号' in col:
|
183
183
|
return 'mediumtext'
|
184
|
+
if '商品编码' in col: # 京东sku/spu商品信息
|
185
|
+
return 'mediumtext'
|
184
186
|
if '文件大小' in col: # bw 程序
|
185
187
|
return 'mediumtext'
|
186
188
|
elif '日期' in col or '时间' in col:
|
@@ -192,8 +194,12 @@ class MysqlUpload:
|
|
192
194
|
elif dtype == 'datetime64[ns]': # 日期可能显示为数字, 因为放在判断 int 的前面
|
193
195
|
return 'DATE'
|
194
196
|
elif dtype == 'int32':
|
197
|
+
if len(str(max(df[col].tolist()))) >= 10: # 数值长度超限转为 mediumtext
|
198
|
+
return 'mediumtext'
|
195
199
|
return 'INT'
|
196
200
|
elif dtype == 'int64':
|
201
|
+
if len(str(max(df[col].tolist()))) >= 10:
|
202
|
+
return 'mediumtext'
|
197
203
|
return 'INT'
|
198
204
|
elif dtype == 'float64':
|
199
205
|
return 'FLOAT'
|
@@ -391,11 +397,19 @@ class OptimizeDatas:
|
|
391
397
|
self.config.update({'database': self.db_name}) # 添加更新 config 字段
|
392
398
|
self.connection = pymysql.connect(**self.config)
|
393
399
|
with self.connection.cursor() as cursor:
|
400
|
+
sql = f"SELECT 1 FROM {table_name} LIMIT 1"
|
401
|
+
cursor.execute(sql)
|
402
|
+
result = cursor.fetchone()
|
403
|
+
if not result:
|
404
|
+
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S ")
|
405
|
+
print(f'{now}数据表: {table_name}, 数据长度为 0')
|
406
|
+
continue # 检查数据表是否为空
|
407
|
+
|
394
408
|
cursor.execute(f"SHOW FULL COLUMNS FROM {table_name}") # 查询数据表的列信息
|
395
409
|
columns = cursor.fetchall()
|
396
410
|
date_exist = False
|
397
411
|
for col in columns: # 遍历列信息,检查是否存在类型为日期的列
|
398
|
-
if col['Field'] == '日期' and col['Type'] == 'date' or col['Type'].startswith('datetime'):
|
412
|
+
if col['Field'] == '日期' and (col['Type'] == 'date' or col['Type'].startswith('datetime')):
|
399
413
|
date_exist = True
|
400
414
|
break
|
401
415
|
if date_exist: # 存在日期列
|
@@ -19,7 +19,7 @@ mdbq/log/mylogger.py,sha256=oaT7Bp-Hb9jZt52seP3ISUuxVcI19s4UiqTeouScBO0,3258
|
|
19
19
|
mdbq/mongo/__init__.py,sha256=SILt7xMtQIQl_m-ik9WLtJSXIVf424iYgCfE_tnQFbw,13
|
20
20
|
mdbq/mongo/mongo.py,sha256=q0B4wXDSTtXg_vMN7MPh6zdxl6tT68tM74LmdVNQQek,31892
|
21
21
|
mdbq/mysql/__init__.py,sha256=A_DPJyAoEvTSFojiI2e94zP0FKtCkkwKP1kYUCSyQzo,11
|
22
|
-
mdbq/mysql/mysql.py,sha256=
|
22
|
+
mdbq/mysql/mysql.py,sha256=nVrnkHWlcttr3Mx0Bdneb04oTlKtbDL9WrAUY4IEnow,31363
|
23
23
|
mdbq/mysql/s_query.py,sha256=mNrdyMeiQ5wQVD_9IDTrk6jrMtszQftYQg3AwNWhROc,6997
|
24
24
|
mdbq/mysql/year_month_day.py,sha256=VgewoE2pJxK7ErjfviL_SMTN77ki8GVbTUcao3vFUCE,1523
|
25
25
|
mdbq/other/__init__.py,sha256=jso1oHcy6cJEfa7udS_9uO5X6kZLoPBF8l3wCYmr5dM,18
|
@@ -30,7 +30,7 @@ mdbq/pbix/__init__.py,sha256=Trtfaynu9RjoTyLLYBN2xdRxTvm_zhCniUkVTAYwcjo,24
|
|
30
30
|
mdbq/pbix/pbix_refresh.py,sha256=JUjKW3bNEyoMVfVfo77UhguvS5AWkixvVhDbw4_MHco,2396
|
31
31
|
mdbq/pbix/refresh_all.py,sha256=wulHs4rivf4Mi0Pii2QR5Nk9-TBcvSwnCB_WH9QULKE,5939
|
32
32
|
mdbq/spider/__init__.py,sha256=RBMFXGy_jd1HXZhngB2T2XTvJqki8P_Fr-pBcwijnew,18
|
33
|
-
mdbq-0.1.
|
34
|
-
mdbq-0.1.
|
35
|
-
mdbq-0.1.
|
36
|
-
mdbq-0.1.
|
33
|
+
mdbq-0.1.8.dist-info/METADATA,sha256=kq2yPANrk7gBwvVYisf2J2CYi2IWBnJJCLh97WNBXdI,245
|
34
|
+
mdbq-0.1.8.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
35
|
+
mdbq-0.1.8.dist-info/top_level.txt,sha256=2FQ-uLnCSB-OwFiWntzmwosW3X2Xqsg0ewh1axsaylA,5
|
36
|
+
mdbq-0.1.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|