发送邮件库
Project description
使用说明
变量环境设置(数据库的链接信息存储在变量环境中)
# 设置环境变量 user 是用户名,password 是密码,192.168.1.10:22484 数据库地址
os.environ['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://user:password@192.168.1.10:22484/'
# 获取环境变量,如果不存在则使用默认值
value = os.environ.get('SQLALCHEMY_DATABASE_URI', 'default_value')
print(value+"DY_DSLP")
1、安装包模块
pip install mjsqltool
pip install --upgrade mjsqltool
2、引入包模块
from mjsqltool import SqlConnect,DataConvert,SqlExecute
SqlConnect
链接数据库,使用完毕后自动关闭
# 数据库名称
db = 'database'
with SqlConnect(db) as cn:
.....
DataConvert
数据转换 1、清洗数据 2、数据转SQL
convert = DataConvert()
df = pd.read_exce("jjjj.xlsx")
# 清洗数据
df = convert.convert_to_cleandata(df)
# 转成SQL语句 sql_type: 保存类型 有两个可选参数 'INSERT' 和 'REPLACE'
data = df
table_name = '测试表格'
sql_type='REPLACE'
query = convert.convert_to_sqlstring(data,table_name, sql_type)
SqlExecute
SqlExecute 将数据保存到MySQL SqlExecute 继承了 DataConvert,
from mjsqltool import SqlConnect,DataConvert,SqlExecute
import pandas as pd
with SqlConnect("MJ_DATA") as cn:
df = pd.read_excel(r"C:\Users\manji\Downloads\联盟订单.xlsx")
SqlExecute().data_cleanerSave_tosql(df,"测试表格",cn)
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
mjsqltool-1.1.7.tar.gz
(9.6 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
mjsqltool-1.1.7-py3-none-any.whl
(10.1 kB
view details)
File details
Details for the file mjsqltool-1.1.7.tar.gz.
File metadata
- Download URL: mjsqltool-1.1.7.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
417621c8dc3748af3366130930f34e8bb72cf9f4ca9bdafe21ebbeb061118999
|
|
| MD5 |
dffa77d0849cf35807414057c730011f
|
|
| BLAKE2b-256 |
9b7d627a73dd3d380f41439168502eca4fc901666f700b24683554304714d7c6
|
File details
Details for the file mjsqltool-1.1.7-py3-none-any.whl.
File metadata
- Download URL: mjsqltool-1.1.7-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccd498d7cd2c7c696d8bf52e2404249f73fa088a54ef4004e9ea51762c4c3cbf
|
|
| MD5 |
cbd00b1fdf03aa125d4ce6f9c11e2bb8
|
|
| BLAKE2b-256 |
a43586684f6ea8d3476bfd006b2c0692c19d7b436a246107d91feaeba4bdb98e
|