mybatis-plus-py
Python implementation of MyBatis-Plus: Pydantic-driven entity mapping, generic CRUD repositories, fluent query builder, multi-dialect support (SQLite / PostgreSQL / MySQL), Druid-style connection pool, and MyBatis-Plus style SQL interceptor pipeline.
Quick Start
pip install mybatis-plus-py
# with database driver extras
pip install mybatis-plus-py[postgres] # or [mysql]
from pydantic import BaseModel
from mybatis_plus import entity, Field, Query, BaseRepository, SQLiteDataSource, EntitySession, SqlExecutor
@entity(table="users")
class User(BaseModel):
id: int = Field(primary_key=True, auto_increment=True)
name: str
age: int = Field(default=18)
ds = SQLiteDataSource(":memory:")
session = EntitySession(SqlExecutor(ds))
session.create_table(User)
session.insert(User(name="Alice", age=30))
# Fluent query
adults = session.select_list(User, Query().gt("age", 18))
# Repository
repo = BaseRepository(User, session)
page = repo.select_page(Query().order_by("id"), page=1, size=10)
Database Support
| Database | Driver | Datasource |
|---|---|---|
| SQLite | stdlib sqlite3 |
SQLiteDataSource |
| PostgreSQL | psycopg2 |
PostgresDataSource |
| MySQL | pymysql |
MySQLDataSource |
Key Features
- Entity mapping —
@entity()+Field()with primary keys, auto-increment, version, soft delete, auto-fill - Fluent query builder —
Query().eq("name", "Tom").gt("age", 18).order_by("id") - Generic CRUD —
BaseRepository[T]with insert, update, delete, select, pagination - Chain wrappers —
ChainQuery(User, session).eq("age", 18).list() - SQL interceptors — MyBatis-Plus style
InnerInterceptor/MybatisPlusInterceptorpipeline withPaginationInnerInterceptor - Connection pool — Druid-style pool with ExceptionSorter, ValidConnectionChecker, RemoveAbandoned, PreparedStatementPool
- Middleware — Tenant, logic delete, optimistic lock, auto-fill, block attack, dynamic table name
Architecture
Entity API / Repository / Chain / ActiveRecord
-> EntitySession
-> SqlBuilder + EntityMetaRegistry
-> SqlExecutor
-> MybatisPlusInterceptor + StatementHandler
-> ParameterHandler / ResultSetHandler
-> DataSource / Dialect
License
Apache-2.0
Metadata
Release files for mybatis-plus-py 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mybatis_plus_py-0.2.0.tar.gz | 110.8 kB | Without provenance | Details for mybatis_plus_py-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mybatis_plus_py-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for mybatis_plus_py-0.2.0-py3-none-any.whl |
Total release size: 211.6 kB
Release files / mybatis_plus_py-0.2.0.tar.gz
| Download URL | mybatis_plus_py-0.2.0.tar.gz |
|---|---|
| Size | 110.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8cd3ce70858d32a412446a340e3ee85920bd3581f7bd2860ff8bee389538dc0
|
|
BLAKE2b-256 checksum How to use checksums |
4818e0f0cf93c7531afc5951af5c3b484b564bf641802161b67842ad5da26660
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / mybatis_plus_py-0.2.0-py3-none-any.whl
| Download URL | mybatis_plus_py-0.2.0-py3-none-any.whl |
|---|---|
| Size | 100.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ba15a35d40ff7cabe4c3f86ad7eb07ad10654035cb3906c50e0f36bdd4bea98
|
|
BLAKE2b-256 checksum How to use checksums |
b67324e8bac6df37c276ae34cc553add035545d5490845c8008881a34fede341
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Security for mybatis-plus-py 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.