当前位置:网站首页>Pandas' to_ SQL function usage
Pandas' to_ SQL function usage
2022-07-27 18:36:00 【zkkkkkkkkkkkkk】
Catalog
1. Introduce related library functions
2. Use pandas Of to_sql take data Data written to mysql
3. see mysql Whether the write is successful
1. Introduce related library functions
import pandas as pd
import pymysql
2. Use pandas Of to_sql take data Data written to mysql
'''
to_sql() Built in parameters :
name : Write to mysql Table name of
con : Connection address
if_exists : append mode ( Optional parameters {‘fail’, ‘replace’, ‘append’}, Default fail)
index : Whether or not to data Of index Write to with data mysql ( Optional parameters {‘True’,‘False’}, The default is True)
'''
'''
account : Host name
password: password
port : Port number
dbName : Library name
'''
# obtain engine
url = f'{account}:{password}@{host}:{port}/{dbName}?charset=utf8'
con = 'mysql+pymysql://' + url
# data by pandas Of dataframe Data objects
data.to_sql(name='sql_demo', con=con, if_exists='append', index=False)
3. see mysql Whether the write is successful
According to the profile information , Use sql Tool connection mysql, Click the corresponding library to find the table we write .
边栏推荐
- 怎么会不喜欢呢,CI/CD中轻松发送邮件
- [mit 6.s081] LEC 9: interrupts notes
- Three consecutive high-frequency interview questions of redis online celebrity: cache penetration? Cache breakdown? Cache avalanche?
- 2021.7.28 notes
- [MIT 6.S081] Lec 10: Multiprocessors and locking 笔记
- @Convert 注解在jpa中进行查询的注意事项
- mysql视图基本操作
- 2021.7.12笔记 内外连接
- Together with Samsung, vivo will promote exynos980 dual-mode 5g mobile phone!
- Super practical! After reading the kubernetes study notes hidden by Alibaba P9, call NB directly
猜你喜欢
随机推荐
Solution to invalid SQL Server connection to server
[MIT 6.S081] Lec 9: Interrupts 笔记
2021.7.12 internal and external connection of notes
Marvell announced the roadmap of its arm server chip, and the performance of the next generation will be twice that of thunderx2
[MIT 6.S081] Lec 1: Introduction and examples 笔记
2. 改变颜色空间及颜色检测
On model training and reasoning of AI deep learning
rsa加解密(兼容微信小程序环境)
[MIT 6.S081] Lab8: locks
Meituan Er Mian: why does redis have sentinels?
Chained storage structure of dynamic linked list 3 queue (linkedqueue Implementation)
[mit 6.s081] LEC 9: interrupts notes
[MIT 6.S081] Lab 3: page tables
虚拟偶像的歌声原来是这样生成的!
2021.8.1笔记 DBA
技术分享| 快对讲综合调度系统
Error launching IDEA
Linked list storage structure of dynamic linked list 2 stack (linkedstack Implementation)
微信小程序微信支付概述
Here comes the first 5g SOC of MediaTek! A77+g77+apu3.0, officially released on November 26!



![[MIT 6.S081] Lec 9: Interrupts 笔记](/img/b6/a8d39aa7ede4eb1c5a74e6d15b3b1c.png)
![[MIT 6.S081] Lab8: locks](/img/9f/0ff7a0226837a3c420f49e6da8209f.png)




