skillfed

pangres

Postgres insert update with pandas DataFrames.

pangres v4.2.1 130.2K downloads/30d#11,650 on PyPI233
Permissive license The Unlicense DORMANT released

What it is and what it does

Pangres bridges pandas DataFrames and SQL databases by implementing upsert operations (insert-or-update) that pandas' native to_sql does not support. It works with PostgreSQL, MySQL, and SQLite, handling ON CONFLICT DO NOTHING and ON CONFLICT DO UPDATE semantics based on primary or unique keys. The package can automatically create missing tables and schemas, add new columns to existing tables, and alter column types when safe—features that simplify data pipeline workflows where you need idempotent writes without manual schema management.

The library includes optional JSON column support, SQL injection protection through parameterized queries, and asynchronous engine support for async/await patterns. It depends on pandas, sqlalchemy, alembic, and packaging. However, the package has been dormant for over 1000 days; the last release was in November 2023 and the last commit in December 2023, raising questions about ongoing maintenance and compatibility with current dependency versions.

Use it for:

  • Incrementally load data from pandas into a production database without duplicating rows or manually managing upsert logic.
  • Automatically create and evolve SQL table schemas from DataFrame structure without writing DDL.
  • Build data pipelines that idempotently write results to PostgreSQL, MySQL, or SQLite using the same code.
  • Insert JSON objects (dicts, lists) into existing JSON columns in PostgreSQL, which pandas to_sql does not support.
  • Async-first applications that need to upsert DataFrames without blocking, using aiosqlite, asyncpg, or aiomysql.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Upserts pandas DataFrames into PostgreSQL, MySQL, and SQLite databases using primary or unique keys, with optional automatic table and schema creation.

Yes, if you are locked into an older dependency ecosystem and need upsert semantics for pandas DataFrames. No, if you require active maintenance or compatibility with the latest sqlalchemy/alembic versions—the package is dormant and may break with dependency updates. Consider alternatives if you need ongoing support or are starting a new project.

Install

pangres on PyPI

pip

pip install pangres

uv

uv add pangres

poetry

poetry add pangres

Installing pangres

Before you install

High install friction due to 4 runtime dependencies (pandas, sqlalchemy, alembic, packaging). Package is dormant—last release was 1013 days ago with no recent commits. For sqlalchemy>=2.0 compatibility, requires alembic>=1.7.2 and pandas>=1.4.0; asynchronous support requires Python>=3.8.

License in practice

Licensed under The Unlicense (permissive public domain), imposing no restrictions on use, modification, or redistribution.

Quickstart

pip install pangres pandas sqlalchemy

import pandas as pd
from sqlalchemy import create_engine
from pangres import upsert

df = pd.DataFrame({'id': [1], 'name': ['test']})
engine = create_engine('sqlite:///test.db')
upsert(engine, df, 'my_table')

SQLite must be version 3.24.4 or higher for UPSERT syntax. For async support, Python>=3.8 required. Database-specific drivers (psycopg2, pymysql, asyncpg, aiomysql, aiosqlite) must be installed separately.

Verify before relying

  • Whether the package works reliably with modern versions of sqlalchemy and alembic given the dormant maintenance status.
  • Current compatibility with Python 3.10 and 3.11 in practice, despite classifiers listing them.
  • Performance characteristics on large datasets relative to alternatives.

Package facts

License The Unlicense (permissive)
Python support not specified
Install friction high — source build required
Runtime dependencies 4 — pandas, sqlalchemy, alembic, packaging
Maintenance dormant — 1,013 days since the last release
Last repo commit
First released
Downloads 130,215/month — #11,650 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pangres-4.2.1.tar.gz

Keywords: pandas, postgres, mysql, sqlite

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: Public DomainOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

pandas dataframe upsert sqlinsert on conflict updatebulk insert pandas databasedataframe to sql with upsertpostgres mysql sqlite upsertautomatic table creation sqljson column pandas sql
pandas-sql-integrationupsert-operationsasync-database

More Database packages