types-PyMySQL
Typing stubs for PyMySQL
What it is and what it does
types-PyMySQL is a type stub package that provides type annotations for the PyMySQL database driver. It allows static type checkers like mypy, pyright, and ty to understand and validate code that uses PyMySQL, catching type errors before runtime. The package is maintained as part of the typeshed project and aims to cover PyMySQL version 1.2.*.
Type stubs are metadata-only packages with no runtime code—they exist purely to inform type checkers about the shape and types of an external library's API. Installing this package does not change how PyMySQL behaves; it only improves the development experience by enabling IDE autocomplete and static analysis of PyMySQL usage.
Use it for:
- Enable mypy or pyright to type-check code that imports and uses PyMySQL without false positives.
- Get IDE autocomplete and inline type hints when writing PyMySQL database queries and connection code.
- Validate function signatures and return types in a codebase that depends on PyMySQL before deployment.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides type stubs for PyMySQL to enable static type checking of code using the PyMySQL database driver.
Yes, if you use PyMySQL and want static type checking. It has no runtime cost, is actively maintained, carries no security vulnerabilities, and is licensed permissively. Install it alongside PyMySQL in your development environment or type-checking pipeline.
Install
types-pymysql on PyPI
pip
pip install types-pymysqluv
uv add types-pymysqlpoetry
poetry add types-pymysqlInstalling types-PyMySQL
Before you install
Low friction install with no runtime dependencies. Actively maintained; latest release was 7 days ago and the package has been updated consistently since its 2021 inception.
License in practice
Licensed under Apache-2.0 (permissive), allowing free use, modification, and distribution with minimal restrictions.
Quickstart
pip install types-PyMySQL
import pymysql
conn = pymysql.connect(host='localhost', user='root', password='', database='test')
Requires Python 3.10 or later.
Verify before relying
- Whether type coverage is complete for all PyMySQL 1.2.* APIs or if gaps remain.
- Compatibility with type checkers beyond those tested: mypy 2.3.0, pyright 1.1.411, ty 0.0.59.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 7 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 13,403,278/month — #1,283 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: types_pymysql-1.2.0.20260807-py3-none-any.whl
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
types-gunicornProvides type stubs for gunicorn to enable…
permissive · top 15,000 on PyPI
types-mysqlclientProvides type annotations for the mysqlclient…
permissive · top 15,000 on PyPI
types-peeweeProvides type annotations for the peewee ORM…
permissive · top 15,000 on PyPI
types-dockerProvides type hints for the docker package,…
permissive · top 5,000 on PyPI
types-grpcioProvides type stubs for the grpcio package,…
permissive · top 5,000 on PyPI
types-shapelyProvides type stubs for the shapely package,…
permissive · top 15,000 on PyPI
types-mypy-extensionsProvides type stubs for mypy-extensions,…
permissive · top 15,000 on PyPI
types-psycopg2Provides type hints for psycopg2, enabling…
permissive · top 5,000 on PyPI
types-pyflakesProvides type stubs for the pyflakes static…
permissive · top 15,000 on PyPI
types-confluent-kafkaProvides type hints and stub files for the…
permissive · top 5,000 on PyPI