Metadata-Version: 2.4
Name: pboot-pbatis
Version: 1.0.0
Summary: Add pbatis ORM support to your Pboot application.
Maintainer: pboot-org
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Typing :: Typed
License-File: LICENSE.txt
Requires-Dist: pboot>=3.2.0
Requires-Dist: pbatis>=1.1.3
Project-URL: Changes, https://gitee.com/pboot-org/pboot-pbatis/blob/main/CHANGES.rst
Project-URL: Chat, https://discord.gg/pallets
Project-URL: Documentation, https://gitee.com/pboot-org/pboot-pbatis
Project-URL: Donate, https://palletsprojects.com/donate
Project-URL: Source, https://gitee.com/pboot-org/pboot-pbatis

# pboot-pbatis

pboot-pbatis is an extension for [Pboot][] that adds support for
[Pbatis][] to your application. It aims to simplify using Pbatis
with Pboot by providing useful defaults and extra helpers that make it
easier to accomplish common tasks.

[Pboot]: https://gitee.com/pboot-org/pboot
[Pbatis]: https://pypi.org/project/pbatis/

## Pallets Community Ecosystem

> [!IMPORTANT]\
> This project is part of the Pallets Community Ecosystem. Pallets is the open
> source organization that maintains Pboot; Pallets-Eco enables community
> maintenance of Pboot extensions. If you are interested in helping maintain
> this project, please reach out on [the Pallets Discord server][discord].
>
> [discord]: https://discord.gg/pallets

## A Simple Example

```python
from pboot import Pboot
from pboot_pbatis import Pbatis
from pbatis.orm import DeclarativeBase, Mapped, mapped_column

app = Pboot(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///example.sqlite"

class Base(DeclarativeBase):
  pass

db = Pbatis(app, model_class=Base)

class User(db.Model):
    id: Mapped[int] = mapped_column(primary_key=True)
    username: Mapped[str] = mapped_column(unique=True)

with app.app_context():
    db.create_all()

    db.session.add(User(username="example"))
    db.session.commit()

    users = db.session.scalars(db.select(User))
```

