Writing JSON column to Postgres using Pandas .to_sql

前端 未结 3 1637
半阙折子戏
半阙折子戏 2021-02-07 05:51

During an ETL process I needed to extract and load a JSON column from one Postgres database to another. We use Pandas for this since it has so many ways to read and write data f

3条回答
  •  日久生厌
    2021-02-07 06:05

    I am unable to comment peralmq's answer, but in case of postgresql JSONB you can use

    from sqlalchemy import dialects
    dataframe.to_sql(..., dtype={"json_column":dialects.postgresql.JSONB})
    

提交回复
热议问题