cppackage 0.2.0__tar.gz → 0.2.1__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.0 → cppackage-0.2.1}/CPpackage/db/sql_model.py +1 -24
- {cppackage-0.2.0 → cppackage-0.2.1}/CPpackage.egg-info/PKG-INFO +7 -6
- {cppackage-0.2.0 → cppackage-0.2.1}/PKG-INFO +7 -6
- {cppackage-0.2.0 → cppackage-0.2.1}/readme.md +6 -5
- {cppackage-0.2.0 → cppackage-0.2.1}/setup.py +1 -1
- {cppackage-0.2.0 → cppackage-0.2.1}/CPpackage/__init__.py +0 -0
- {cppackage-0.2.0 → cppackage-0.2.1}/CPpackage/core/__init__.py +0 -0
- {cppackage-0.2.0 → cppackage-0.2.1}/CPpackage/db/__init__.py +0 -0
- {cppackage-0.2.0 → cppackage-0.2.1}/CPpackage/db/config.py +0 -0
- {cppackage-0.2.0 → cppackage-0.2.1}/CPpackage/utils/__init__.py +0 -0
- {cppackage-0.2.0 → cppackage-0.2.1}/CPpackage.egg-info/SOURCES.txt +0 -0
- {cppackage-0.2.0 → cppackage-0.2.1}/CPpackage.egg-info/dependency_links.txt +0 -0
- {cppackage-0.2.0 → cppackage-0.2.1}/CPpackage.egg-info/entry_points.txt +0 -0
- {cppackage-0.2.0 → cppackage-0.2.1}/CPpackage.egg-info/not-zip-safe +0 -0
- {cppackage-0.2.0 → cppackage-0.2.1}/CPpackage.egg-info/requires.txt +0 -0
- {cppackage-0.2.0 → cppackage-0.2.1}/CPpackage.egg-info/top_level.txt +0 -0
- {cppackage-0.2.0 → cppackage-0.2.1}/LICENSE +0 -0
- {cppackage-0.2.0 → cppackage-0.2.1}/MANIFEST.in +0 -0
- {cppackage-0.2.0 → cppackage-0.2.1}/setup.cfg +0 -0
|
@@ -47,29 +47,6 @@ def sel_data(sql, params=None, port=None, database=None):
|
|
|
47
47
|
return None
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
def update_data(sql, values, port=None, database=None):
|
|
51
|
-
|
|
52
|
-
try:
|
|
53
|
-
with _get_connection(database, port) as conn:
|
|
54
|
-
with conn.cursor() as cursor:
|
|
55
|
-
cursor.execute(sql, values)
|
|
56
|
-
conn.commit()
|
|
57
|
-
|
|
58
|
-
except pymysql.MySQLError as e:
|
|
59
|
-
print("更新失败:", e)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
def update_datas(sql, values, port=None, database=None):
|
|
63
|
-
|
|
64
|
-
try:
|
|
65
|
-
with _get_connection(database, port) as conn:
|
|
66
|
-
with conn.cursor() as cursor:
|
|
67
|
-
cursor.executemany(sql, values)
|
|
68
|
-
conn.commit()
|
|
69
|
-
|
|
70
|
-
except pymysql.MySQLError as e:
|
|
71
|
-
print("批量更新失败:", e)
|
|
72
|
-
|
|
73
50
|
|
|
74
51
|
def del_data(sql, params=None, port=None, database=None):
|
|
75
52
|
|
|
@@ -151,7 +128,7 @@ def check_and_sync_columns(df, table_name, database, max_new=5):
|
|
|
151
128
|
|
|
152
129
|
# ===================== DataFrame 入库 =====================
|
|
153
130
|
|
|
154
|
-
def
|
|
131
|
+
def update_datas(df, table_name, database):
|
|
155
132
|
|
|
156
133
|
conn = None
|
|
157
134
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cppackage
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: 超品集团自用的Python包
|
|
5
5
|
Home-page: https://github.com/example/CPpackage
|
|
6
6
|
Author: team-数智组
|
|
@@ -47,15 +47,16 @@ pip install CPpackage
|
|
|
47
47
|
|
|
48
48
|
```python
|
|
49
49
|
# 导入包
|
|
50
|
-
from CPpackage.db import set_db_config
|
|
51
|
-
from CPpackage.db.sql_model import sel_data,
|
|
50
|
+
from CPpackage.db.config import set_db_config
|
|
51
|
+
from CPpackage.db.sql_model import sel_data, del_data , get_table_columns,add_columns,check_and_sync_columns,update_datas
|
|
52
52
|
|
|
53
53
|
# 配置数据库连接(也可通过环境变量CPPACKAGE_DB_*配置)
|
|
54
54
|
set_db_config(host='your_host', user='your_user', password='your_password', database='your_database', port=3306)
|
|
55
55
|
|
|
56
|
-
#
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
# 更新数据函数,在完成数据库信息配置后,df为pd.dataframe格式的数据
|
|
57
|
+
# 更新过程会先经过check_and_sync_columns函数完成表格校验
|
|
58
|
+
update_datas(df, table_name, database)
|
|
59
|
+
|
|
59
60
|
```
|
|
60
61
|
|
|
61
62
|
## 项目结构
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cppackage
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: 超品集团自用的Python包
|
|
5
5
|
Home-page: https://github.com/example/CPpackage
|
|
6
6
|
Author: team-数智组
|
|
@@ -47,15 +47,16 @@ pip install CPpackage
|
|
|
47
47
|
|
|
48
48
|
```python
|
|
49
49
|
# 导入包
|
|
50
|
-
from CPpackage.db import set_db_config
|
|
51
|
-
from CPpackage.db.sql_model import sel_data,
|
|
50
|
+
from CPpackage.db.config import set_db_config
|
|
51
|
+
from CPpackage.db.sql_model import sel_data, del_data , get_table_columns,add_columns,check_and_sync_columns,update_datas
|
|
52
52
|
|
|
53
53
|
# 配置数据库连接(也可通过环境变量CPPACKAGE_DB_*配置)
|
|
54
54
|
set_db_config(host='your_host', user='your_user', password='your_password', database='your_database', port=3306)
|
|
55
55
|
|
|
56
|
-
#
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
# 更新数据函数,在完成数据库信息配置后,df为pd.dataframe格式的数据
|
|
57
|
+
# 更新过程会先经过check_and_sync_columns函数完成表格校验
|
|
58
|
+
update_datas(df, table_name, database)
|
|
59
|
+
|
|
59
60
|
```
|
|
60
61
|
|
|
61
62
|
## 项目结构
|
|
@@ -14,15 +14,16 @@ pip install CPpackage
|
|
|
14
14
|
|
|
15
15
|
```python
|
|
16
16
|
# 导入包
|
|
17
|
-
from CPpackage.db import set_db_config
|
|
18
|
-
from CPpackage.db.sql_model import sel_data,
|
|
17
|
+
from CPpackage.db.config import set_db_config
|
|
18
|
+
from CPpackage.db.sql_model import sel_data, del_data , get_table_columns,add_columns,check_and_sync_columns,update_datas
|
|
19
19
|
|
|
20
20
|
# 配置数据库连接(也可通过环境变量CPPACKAGE_DB_*配置)
|
|
21
21
|
set_db_config(host='your_host', user='your_user', password='your_password', database='your_database', port=3306)
|
|
22
22
|
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
# 更新数据函数,在完成数据库信息配置后,df为pd.dataframe格式的数据
|
|
24
|
+
# 更新过程会先经过check_and_sync_columns函数完成表格校验
|
|
25
|
+
update_datas(df, table_name, database)
|
|
26
|
+
|
|
26
27
|
```
|
|
27
28
|
|
|
28
29
|
## 项目结构
|
|
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
|