惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
WordPress大学
WordPress大学
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
CXSECURITY Database RSS Feed - CXSecurity.com
I
Intezer
V
Visual Studio Blog
Cisco Talos Blog
Cisco Talos Blog
Microsoft Azure Blog
Microsoft Azure Blog
S
Securelist
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
N
News and Events Feed by Topic
Recorded Future
Recorded Future
Simon Willison's Weblog
Simon Willison's Weblog
G
GRAHAM CLULEY
酷 壳 – CoolShell
酷 壳 – CoolShell
L
Lohrmann on Cybersecurity
U
Unit 42
Hacker News: Ask HN
Hacker News: Ask HN
阮一峰的网络日志
阮一峰的网络日志
Vercel News
Vercel News
PCI Perspectives
PCI Perspectives
H
Help Net Security
C
Cisco Blogs
爱范儿
爱范儿
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
小众软件
小众软件
T
Tor Project blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Schneier on Security
Schneier on Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
www.infosecurity-magazine.com
www.infosecurity-magazine.com
IT之家
IT之家
J
Java Code Geeks
人人都是产品经理
人人都是产品经理
Spread Privacy
Spread Privacy
T
The Blog of Author Tim Ferriss
Application and Cybersecurity Blog
Application and Cybersecurity Blog
AI
AI
S
Security @ Cisco Blogs
T
Tenable Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cloudbric
Cloudbric
D
Docker
W
WeLiveSecurity
Hacker News - Newest:
Hacker News - Newest: "LLM"
F
Fortinet All Blogs
The Hacker News
The Hacker News
Help Net Security
Help Net Security

博客园 - 朕也就是个普通人

毕业快11年了,我仍是程序猿 平凡的生活~ 反思亲子相处~ cxf RESTful service client cucumber 加油 重新学习python爬虫 python 网址 《高兴》 贾平凹 摘抄 funny python ML 算法 tensorflow 机器学习(Machine Learning) Eureka 注册中心 和 Config中心 配置 最近的日子-2019/8/12 工作上的态度 保持运动 对心情很重要 读《Linux命令行与shell脚本编程大全.第3版》 我的老妈挺可爱 看看书
Python + sqlalchemy + Pandas + Mysql 实现自动创建表,插入数据
朕也就是个普通人 · 2020-08-19 · via 博客园 - 朕也就是个普通人

python 脚本示例:

import pandas as pd
import mysql.connector
from sqlalchemy import create_engine

data = pd.DataFrame({'name': ['User 周', 'User 李', 'User 王']})
engine = create_engine("mysql+mysqlconnector://root:123456@localhost:3306/testdb?charset=utf8")
data.to_sql("test_table", engine, index=False)

运行上段代码,在数据库中会新增test_table表,但是因为插入中文,会遇到编码的exception。

so 需要把mysql数据库编码修改为 utf8bm4: 可参照此链接

https://blog.csdn.net/qq_35028064/article/details/83657264

请注意,配置修改后,需重启数据库服务才生效,重启数据库服务命令:

net stop mysql

net start mysql

不同数据库使用sqlalchemy, 参考:

https://docs.sqlalchemy.org/en/13/core/engines.html