Some useful and common tools.
Project description
sql-data
一款用于mysql数据查询存储+时间格式化处理得工具
使用方式
1、安装 pip install sql-data==0.1.5
2、
# 用于创建config默认配置并返回文件位置,请按照默认格式进行个人mysql数据库得配置
config_path = sql_data.get_config_path()
[127.0.0.1]
HOST = 127.0.0.1
PORT = 3306
DB_USER = root
DB_PWD = 12345
内置函数
from sql_data import exec_sql_mysql, get_data_from_mysql, saved_data_to_mysql
from sql_data import date_fmt
sql = "select * from mysql_table"
# 获取数据 -> DataFrom
data_df = sql_data.get_data_from_mysql(sql, "db_name", "127.0.0.1")
# 数据存储
sql_data.saved_data_to_mysql(sql, "db_name", "127.0.0.1")
exec_sql = "delect from mysql_table"
## 数据删除、更改和插入
sql_data.exec_sql_mysql(exec_sql, "db_name", "127.0.0.1")
date_value = ["2022年08月08日 19:19",
"2022年08月08日",
"2022-08-08 19:40",
"2022-08-08 10:55:32",
"08/8/2022",
"08-08-22",
"2022.8",
"20220808"]
date_df = pd.DataFrame(date_value, columns=["time"])
# 对符合以上日期格式得列进行格式化转换 -> Y-M-D
date_fmt_df = date_fmt.column_fmt(date_df)
import datetime as dt
# today = "2022-09-01" or
today = dt.date.today()
# 返回days天之后得日期,days<0则计算之前日期
fmt_date = date_fmt.day_add(today, days=7)
# 返回weeks周之后得日期,weeks<0则计算之前日期, what_day取值: [1, 7],设置返回值为星期几得日期
fmt_date = date_fmt.week_add(today, what_day=1, weeks=0)
# 返回months月之后得日期,months<0则计算之前日期,begin=True为月初日期,begin=False为月末日期
fmt_date = date_fmt.month_add(today, months=0, begin=True)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cj_tools-0.1.1.tar.gz
(7.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cj_tools-0.1.1.tar.gz.
File metadata
- Download URL: cj_tools-0.1.1.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e0843e5f91bb037c763a088937f7da200cbfc31cc93543e0dbbdab720562307
|
|
| MD5 |
4df6cf75a7939e3cafb57e475d97b61a
|
|
| BLAKE2b-256 |
85587c26884d7babff232196d05168b824db8aaa1d4a752b1deccfbe4aa533c1
|
File details
Details for the file cj_tools-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cj_tools-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f532ffe6843c027e2b91dd40ab4b4344589178f1833803fa5b785edd4cda228
|
|
| MD5 |
cd840e4530bd719282dd5201dfeca82f
|
|
| BLAKE2b-256 |
2c8d69755cd3c1a970a81f19261e662c4640730a25f7c6314e738cb972f2248b
|