pandasql
sqldf for pandas
What it is and what it does
pandasql is a thin wrapper that translates SQL queries into pandas operations, using SQLite syntax as the query language. It automatically detects pandas DataFrames in the calling scope and treats them as SQL tables, allowing you to write SELECT, JOIN, GROUP BY, and other SQL statements against them. The main entry point is the sqldf function, which takes a SQL query string and a namespace dict (typically globals() or locals()) to resolve DataFrame names.
The package was designed to lower the barrier for people familiar with SQL but new to pandas, providing a more intuitive interface for data manipulation and cleaning. However, it has been abandoned since 2016 with no active maintenance, creating significant compatibility concerns for modern Python and pandas environments.
Use it for:
- Migrate SQL-based data workflows to Python without rewriting queries as pandas method chains
- Join multiple DataFrames using familiar SQL INNER/LEFT/RIGHT JOIN syntax
- Perform GROUP BY aggregations and window functions on DataFrames using SQL
- Prototype data transformations quickly if you think in SQL rather than pandas idioms
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
pandasql lets you query pandas DataFrames using SQL syntax instead of pandas methods, bridging SQL familiarity with DataFrame manipulation.
No. The package is abandoned (last release 2016, no commits since July 2024 in archived repo) and has high install friction. Modern alternatives like DuckDB or Polars provide SQL-on-DataFrames with active maintenance, better performance, and compatibility with current Python versions. Use pandasql only if you have legacy code already depending on it; do not start new projects with it.
Install
pandasql on PyPI
pip
pip install pandasqluv
uv add pandasqlpoetry
poetry add pandasqlInstalling pandasql
Before you install
High install friction due to distribution format (egg and tarball only, no wheels). Package is abandoned as of 2016 with no maintenance since then, creating compatibility risk with modern Python and pandas versions.
License in practice
MIT-like permissive license (copyright notice and permission text present) with no SPDX identifier recorded. Permissive for use but license treatment is marked unclear, so verify the exact terms before relying on it commercially.
Quickstart
pip install pandasql
from pandasql import sqldf
pysqldf = lambda q: sqldf(q, globals())
result = pysqldf("SELECT * FROM my_dataframe LIMIT 10;")
Requires pandas to be installed separately; no explicit Python version support declared. Abandoned package may have compatibility issues with modern Python and pandas versions.
Verify before relying
- Whether pandasql works with current pandas versions (last release 2016, pandas has evolved significantly)
- Exact Python version compatibility (requires_python is unspecified)
- Whether SQLite syntax coverage is complete for modern SQL features
Package facts
| License | Copyright (c) 2013 Yhat, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the… (full text in the JSON record) (unclear) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | abandoned — 3,768 days since the last release |
| Last repo commit | (repository archived) |
| First released | |
| Downloads | 1,963,671/month — #3,405 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pandasql-0.7.3-py2.7.egg; pandasql-0.7.3.tar.gz
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
qpdQPD translates SQL SELECT statements into…
permissive · top 15,000 on PyPI
connectorxConnectorX loads data from databases directly…
permissive · top 5,000 on PyPI
pandas-gbqpandas-gbq reads data from Google BigQuery into…
permissive · top 1,000 on PyPI
cloudsearchWrapper for AWS CloudSearch that simplifies…
permissive · top 15,000 on PyPI
ipython-sqlAdds SQL magic commands to IPython and Jupyter…
permissive · top 15,000 on PyPI
stats-canFetches Statistics Canada data through the Web…
copyleft · top 15,000 on PyPI
bigframesBigFrames provides a pandas-compatible…
permissive · top 5,000 on PyPI
ibis-frameworkIbis is a portable Python dataframe library…
permissive · top 5,000 on PyPI
pandasaiPandasAI lets you ask questions about your data…
permissive · top 15,000 on PyPI
pangresUpserts pandas DataFrames into PostgreSQL,…
permissive · top 15,000 on PyPI