推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
QGabriel
V2EX  ›  Python

如何遍历 dataframe 数据插入 pymysql 里?

  •  
  •   QGabriel · Nov 4, 2021 · 2939 views
    This topic created in 1835 days ago, the information mentioned may be changed or developed.
    一个 6000 行的 dataframe,遍历每行存到 sql 里.
    之前都用 MongoDB 换了 sql 不会用了
    6 replies  •  2021-11-04 17:48:10 +08:00
    imn1
    imn1
    Nov 4, 2021
    1
    遍历 df.itertuples(index=False)
    至于写入 mysql ,还是自己看手册吧
    mmrindextt
    mmrindextt
    Nov 4, 2021
    2
    直接映射成 orm 实体,批量 CRUD
    QGabriel
    QGabriel
    OP
    Nov 4, 2021
    3
    @mmrindextt 谢谢
    mjawp
    mjawp
    Nov 4, 2021
    4
    不是有个 df.to_sql 嘛
    NCZkevin
    NCZkevin
    Nov 4, 2021
    5
    转成 list,写好 sql 语句,直接 executemany(sql,data)
    ipwx
    ipwx
    Nov 4, 2021
    6
    executemany
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1044 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 23:16 · PVG 07:16 · LAX 15:16 · JFK 18:16
    ♥ Do have faith in what you're doing.