Update 2025-04-24_11:44:19

This commit is contained in:
oib
2025-04-24 11:44:23 +02:00
commit e748c737f4
3408 changed files with 717481 additions and 0 deletions

View File

@ -0,0 +1,260 @@
Metadata-Version: 2.1
Name: sqlmodel
Version: 0.0.24
Summary: SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness.
Author-Email: =?utf-8?q?Sebasti=C3=A1n_Ram=C3=ADrez?= <tiangolo@gmail.com>
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Database
Classifier: Topic :: Database :: Database Engines/Servers
Classifier: Topic :: Internet
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Typing :: Typed
Project-URL: Homepage, https://github.com/fastapi/sqlmodel
Project-URL: Documentation, https://sqlmodel.tiangolo.com
Project-URL: Repository, https://github.com/fastapi/sqlmodel
Project-URL: Issues, https://github.com/fastapi/sqlmodel/issues
Project-URL: Changelog, https://sqlmodel.tiangolo.com/release-notes/
Requires-Python: >=3.7
Requires-Dist: SQLAlchemy<2.1.0,>=2.0.14
Requires-Dist: pydantic<3.0.0,>=1.10.13
Description-Content-Type: text/markdown
<p align="center">
<a href="https://sqlmodel.tiangolo.com"><img src="https://sqlmodel.tiangolo.com/img/logo-margin/logo-margin-vector.svg#only-light" alt="SQLModel"></a>
</p>
<p align="center">
<em>SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness.</em>
</p>
<p align="center">
<a href="https://github.com/fastapi/sqlmodel/actions?query=workflow%3ATest+event%3Apush+branch%3Amain" target="_blank">
<img src="https://github.com/fastapi/sqlmodel/actions/workflows/test.yml/badge.svg?event=push&branch=main" alt="Test">
</a>
<a href="https://github.com/fastapi/sqlmodel/actions?query=workflow%3APublish" target="_blank">
<img src="https://github.com/fastapi/sqlmodel/actions/workflows/publish.yml/badge.svg" alt="Publish">
</a>
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/fastapi/sqlmodel" target="_blank">
<img src="https://coverage-badge.samuelcolvin.workers.dev/fastapi/sqlmodel.svg" alt="Coverage">
<a href="https://pypi.org/project/sqlmodel" target="_blank">
<img src="https://img.shields.io/pypi/v/sqlmodel?color=%2334D058&label=pypi%20package" alt="Package version">
</a>
</p>
---
**Documentation**: <a href="https://sqlmodel.tiangolo.com" target="_blank">https://sqlmodel.tiangolo.com</a>
**Source Code**: <a href="https://github.com/fastapi/sqlmodel" target="_blank">https://github.com/fastapi/sqlmodel</a>
---
SQLModel is a library for interacting with <abbr title='Also called "Relational databases"'>SQL databases</abbr> from Python code, with Python objects. It is designed to be intuitive, easy to use, highly compatible, and robust.
**SQLModel** is based on Python type annotations, and powered by <a href="https://pydantic-docs.helpmanual.io/" class="external-link" target="_blank">Pydantic</a> and <a href="https://sqlalchemy.org/" class="external-link" target="_blank">SQLAlchemy</a>.
The key features are:
* **Intuitive to write**: Great editor support. <abbr title="also known as auto-complete, autocompletion, IntelliSense">Completion</abbr> everywhere. Less time debugging. Designed to be easy to use and learn. Less time reading docs.
* **Easy to use**: It has sensible defaults and does a lot of work underneath to simplify the code you write.
* **Compatible**: It is designed to be compatible with **FastAPI**, Pydantic, and SQLAlchemy.
* **Extensible**: You have all the power of SQLAlchemy and Pydantic underneath.
* **Short**: Minimize code duplication. A single type annotation does a lot of work. No need to duplicate models in SQLAlchemy and Pydantic.
## Sponsors
<!-- sponsors -->
<a href="https://www.govcert.lu" target="_blank" title="This project is being supported by GOVCERT.LU"><img src="https://sqlmodel.tiangolo.com/img/sponsors/govcert.png"></a>
<!-- /sponsors -->
## SQL Databases in FastAPI
<a href="https://fastapi.tiangolo.com" target="_blank"><img src="https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png" style="width: 20%;"></a>
**SQLModel** is designed to simplify interacting with SQL databases in <a href="https://fastapi.tiangolo.com" class="external-link" target="_blank">FastAPI</a> applications, it was created by the same <a href="https://tiangolo.com/" class="external-link" target="_blank">author</a>. 😁
It combines SQLAlchemy and Pydantic and tries to simplify the code you write as much as possible, allowing you to reduce the **code duplication to a minimum**, but while getting the **best developer experience** possible.
**SQLModel** is, in fact, a thin layer on top of **Pydantic** and **SQLAlchemy**, carefully designed to be compatible with both.
## Requirements
A recent and currently supported <a href="https://www.python.org/downloads/" class="external-link" target="_blank">version of Python</a>.
As **SQLModel** is based on **Pydantic** and **SQLAlchemy**, it requires them. They will be automatically installed when you install SQLModel.
## Installation
Make sure you create a <a href="https://sqlmodel.tiangolo.com/virtual-environments/" class="external-link" target="_blank">virtual environment</a>, activate it, and then install SQLModel, for example with:
<div class="termy">
```console
$ pip install sqlmodel
---> 100%
Successfully installed sqlmodel
```
</div>
## Example
For an introduction to databases, SQL, and everything else, see the <a href="https://sqlmodel.tiangolo.com/databases/" target="_blank">SQLModel documentation</a>.
Here's a quick example. ✨
### A SQL Table
Imagine you have a SQL table called `hero` with:
* `id`
* `name`
* `secret_name`
* `age`
And you want it to have this data:
| id | name | secret_name | age |
-----|------|-------------|------|
| 1 | Deadpond | Dive Wilson | null |
| 2 | Spider-Boy | Pedro Parqueador | null |
| 3 | Rusty-Man | Tommy Sharp | 48 |
### Create a SQLModel Model
Then you could create a **SQLModel** model like this:
```Python
from typing import Optional
from sqlmodel import Field, SQLModel
class Hero(SQLModel, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
name: str
secret_name: str
age: Optional[int] = None
```
That class `Hero` is a **SQLModel** model, the equivalent of a SQL table in Python code.
And each of those class attributes is equivalent to each **table column**.
### Create Rows
Then you could **create each row** of the table as an **instance** of the model:
```Python
hero_1 = Hero(name="Deadpond", secret_name="Dive Wilson")
hero_2 = Hero(name="Spider-Boy", secret_name="Pedro Parqueador")
hero_3 = Hero(name="Rusty-Man", secret_name="Tommy Sharp", age=48)
```
This way, you can use conventional Python code with **classes** and **instances** that represent **tables** and **rows**, and that way communicate with the **SQL database**.
### Editor Support
Everything is designed for you to get the best developer experience possible, with the best editor support.
Including **autocompletion**:
<img class="shadow" src="https://sqlmodel.tiangolo.com/img/index/autocompletion01.png">
And **inline errors**:
<img class="shadow" src="https://sqlmodel.tiangolo.com/img/index/inline-errors01.png">
### Write to the Database
You can learn a lot more about **SQLModel** by quickly following the **tutorial**, but if you need a taste right now of how to put all that together and save to the database, you can do this:
```Python hl_lines="18 21 23-27"
from typing import Optional
from sqlmodel import Field, Session, SQLModel, create_engine
class Hero(SQLModel, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
name: str
secret_name: str
age: Optional[int] = None
hero_1 = Hero(name="Deadpond", secret_name="Dive Wilson")
hero_2 = Hero(name="Spider-Boy", secret_name="Pedro Parqueador")
hero_3 = Hero(name="Rusty-Man", secret_name="Tommy Sharp", age=48)
engine = create_engine("sqlite:///database.db")
SQLModel.metadata.create_all(engine)
with Session(engine) as session:
session.add(hero_1)
session.add(hero_2)
session.add(hero_3)
session.commit()
```
That will save a **SQLite** database with the 3 heroes.
### Select from the Database
Then you could write queries to select from that same database, for example with:
```Python hl_lines="15-18"
from typing import Optional
from sqlmodel import Field, Session, SQLModel, create_engine, select
class Hero(SQLModel, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
name: str
secret_name: str
age: Optional[int] = None
engine = create_engine("sqlite:///database.db")
with Session(engine) as session:
statement = select(Hero).where(Hero.name == "Spider-Boy")
hero = session.exec(statement).first()
print(hero)
```
### Editor Support Everywhere
**SQLModel** was carefully designed to give you the best developer experience and editor support, **even after selecting data** from the database:
<img class="shadow" src="https://sqlmodel.tiangolo.com/img/index/autocompletion02.png">
## SQLAlchemy and Pydantic
That class `Hero` is a **SQLModel** model.
But at the same time, ✨ it is a **SQLAlchemy** model ✨. So, you can combine it and use it with other SQLAlchemy models, or you could easily migrate applications with SQLAlchemy to **SQLModel**.
And at the same time, ✨ it is also a **Pydantic** model ✨. You can use inheritance with it to define all your **data models** while avoiding code duplication. That makes it very easy to use with **FastAPI**.
## License
This project is licensed under the terms of the [MIT license](https://github.com/fastapi/sqlmodel/blob/main/LICENSE).

View File

@ -0,0 +1,41 @@
sqlmodel-0.0.24.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
sqlmodel-0.0.24.dist-info/METADATA,sha256=Sqk5L8OKfGKa-1b-a4QLfObjqVPopzRjNPNETKn_Z2c,10220
sqlmodel-0.0.24.dist-info/RECORD,,
sqlmodel-0.0.24.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
sqlmodel-0.0.24.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
sqlmodel-0.0.24.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
sqlmodel-0.0.24.dist-info/licenses/LICENSE,sha256=rMFojiOmwoHnB9y2ARj0V2XJ_EMwtfp3X-JamCufffU,1086
sqlmodel/__init__.py,sha256=G_bSH02H0BNZtOwVLEnqtYUE2BU1koS0O14a8ZxfglE,6767
sqlmodel/__pycache__/__init__.cpython-311.pyc,,
sqlmodel/__pycache__/_compat.cpython-311.pyc,,
sqlmodel/__pycache__/default.cpython-311.pyc,,
sqlmodel/__pycache__/main.cpython-311.pyc,,
sqlmodel/_compat.py,sha256=6G-sSDNgSQSDLiEjJVeYVHMGueX86wZhFngSp5RUVs0,22012
sqlmodel/default.py,sha256=2n3-DdAqbRb9u9ywk3icHG6k_3Z0tVoAdlW1auIOAec,850
sqlmodel/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
sqlmodel/ext/__pycache__/__init__.cpython-311.pyc,,
sqlmodel/ext/asyncio/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
sqlmodel/ext/asyncio/__pycache__/__init__.cpython-311.pyc,,
sqlmodel/ext/asyncio/__pycache__/session.cpython-311.pyc,,
sqlmodel/ext/asyncio/session.py,sha256=Hn4SPFxaNiSP-3CgKjoySG--KGrId5MRzgDrbQHTIgQ,4954
sqlmodel/main.py,sha256=U9QU1c_YJGOy92rTozHoAAdlxERvKtVCZrZINJ_d1cw,37223
sqlmodel/orm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
sqlmodel/orm/__pycache__/__init__.cpython-311.pyc,,
sqlmodel/orm/__pycache__/session.cpython-311.pyc,,
sqlmodel/orm/session.py,sha256=KxsdrSB1qQdK45fxIjAtngnCoV2_8HRSd1vgLEqxl5c,5221
sqlmodel/pool/__init__.py,sha256=xvU9k_CW09bLQL6EubYC1gnj1Vket4KNHt-RTs7pHic,67
sqlmodel/pool/__pycache__/__init__.cpython-311.pyc,,
sqlmodel/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
sqlmodel/sql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
sqlmodel/sql/__pycache__/__init__.cpython-311.pyc,,
sqlmodel/sql/__pycache__/_expression_select_cls.cpython-311.pyc,,
sqlmodel/sql/__pycache__/_expression_select_gen.cpython-311.pyc,,
sqlmodel/sql/__pycache__/base.cpython-311.pyc,,
sqlmodel/sql/__pycache__/expression.cpython-311.pyc,,
sqlmodel/sql/__pycache__/sqltypes.cpython-311.pyc,,
sqlmodel/sql/_expression_select_cls.py,sha256=CwAs1TnccCK53WdCE8qiZQJ7F1TFyU1OScgrz99fnKA,1546
sqlmodel/sql/_expression_select_gen.py,sha256=T3sfn62f3TK4ZnKccYM4OZ1kmfp-RifcTi232ey78Qw,7004
sqlmodel/sql/_expression_select_gen.py.jinja2,sha256=lmUND04Nwl40hhH3bkXiP8HCcSK8Qdkji9aKVhnmAQw,1556
sqlmodel/sql/base.py,sha256=VZeuFLTWhuDSr_hemLbWC8fJ8mfGUeeV2GZD5omLTZM,170
sqlmodel/sql/expression.py,sha256=59Aah3M0w-VeYnPHqlm_U2zkQQab7YGLIq6Cmm5GvFo,6373
sqlmodel/sql/sqltypes.py,sha256=O4wq7mYXRlbfrOZMCUuFsskJkIj6kJu5DFvN2JcqlyI,558

View File

@ -0,0 +1,4 @@
Wheel-Version: 1.0
Generator: pdm-backend (2.4.3)
Root-Is-Purelib: true
Tag: py3-none-any

View File

@ -0,0 +1,4 @@
[console_scripts]
[gui_scripts]

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2021 Sebastián Ramírez
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 Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.