python-pandas and databases like mysql

后端 未结 13 2138
有刺的猬
有刺的猬 2020-12-02 03:51

The documentation for Pandas has numerous examples of best practices for working with data stored in various formats.

However, I am unable to find any good examples

13条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-02 04:29

    For recent readers of this question: pandas have the following warning in their docs for version 14.0:

    Warning: Some of the existing functions or function aliases have been deprecated and will be removed in future versions. This includes: tquery, uquery, read_frame, frame_query, write_frame.

    And:

    Warning: The support for the ‘mysql’ flavor when using DBAPI connection objects has been deprecated. MySQL will be further supported with SQLAlchemy engines (GH6900).

    This makes many of the answers here outdated. You should use sqlalchemy:

    from sqlalchemy import create_engine
    import pandas as pd
    engine = create_engine('dialect://user:pass@host:port/schema', echo=False)
    f = pd.read_sql_query('SELECT * FROM mytable', engine, index_col = 'ID')
    

提交回复
热议问题