推荐学习书目
› 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 · 2809 views
    This topic created in 1785 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
        1
    imn1  
       Nov 4, 2021
    遍历 df.itertuples(index=False)
    至于写入 mysql ,还是自己看手册吧
    mmrindextt
        2
    mmrindextt  
       Nov 4, 2021
    直接映射成 orm 实体,批量 CRUD
    QGabriel
        3
    QGabriel  
    OP
       Nov 4, 2021
    @mmrindextt 谢谢
    mjawp
        4
    mjawp  
       Nov 4, 2021
    不是有个 df.to_sql 嘛
    NCZkevin
        5
    NCZkevin  
       Nov 4, 2021
    转成 list,写好 sql 语句,直接 executemany(sql,data)
    ipwx
        6
    ipwx  
       Nov 4, 2021
    executemany
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2290 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 00:40 · PVG 08:40 · LAX 17:40 · JFK 20:40
    ♥ Do have faith in what you're doing.