pangres
Postgres insert update with pandas DataFrames.
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 pangresuv
uv add pangrespoetry
poetry add pangresInstalling 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
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
connectorxConnectorX loads data from databases directly…
permissive · top 5,000 on PyPI
SQLAlchemy-JSONFieldProvides a SQLAlchemy column type for storing…
permissive · top 5,000 on PyPI
pysqlsyncSynchronize database schemas and bulk-load data…
permissive · top 15,000 on PyPI
ipython-sqlAdds SQL magic commands to IPython and Jupyter…
permissive · top 15,000 on PyPI
qpdQPD translates SQL SELECT statements into…
permissive · top 15,000 on PyPI
django-postgres-extraExtends Django's ORM to expose…
permissive · top 15,000 on PyPI
fastlitefastlite wraps sqlite-utils to provide…
permissive · top 15,000 on PyPI
pandasqlpandasql lets you query pandas DataFrames using…
unclear · top 5,000 on PyPI
ddlparseParses CREATE TABLE DDL statements from MySQL,…
permissive · top 15,000 on PyPI
beam-nuggetsProvides Apache Beam transforms for reading and…
permissive · top 15,000 on PyPI