Leichtgewichtiges, dialekt-fähiges Mini-ORM für SQLite, PostgreSQL und MySQL
Project description
pyorm
Leichtgewichtiges Mini-ORM für SQLite, PostgreSQL und MySQL — kein SQLAlchemy,
keine Migrationen, kein globaler Connection-State. Database-Instanzen werden
explizit erzeugt und an jeden Model-Aufruf durchgereicht.
Installation
pip install -e .[dev] # nur SQLite (stdlib)
pip install -e .[dev,postgres] # + psycopg2
pip install -e .[dev,mysql] # + mysql-connector-python
Beispiel
from pyorm import Database, BaseModel
class User(BaseModel):
__table__ = "users"
__primary_key__ = "id"
__slots__ = ("id", "name", "email", "_db")
db = Database.sqlite(":memory:")
db.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)")
user = User.create(db, name="Ada", email="ada@example.com")
found = User.get(db, id=user.id)
with db.transaction():
found.update(name="Ada Lovelace")
Für Postgres/MySQL statt Database.sqlite(...):
db = Database.postgres(host="localhost", dbname="app", user="app", password="...")
db = Database.mysql(host="localhost", database="app", user="app", password="...")
Tests
pytest # SQLite-Tests laufen immer
PYORM_TEST_PG_DSN="host=localhost dbname=test user=test password=test" pytest
PYORM_TEST_MYSQL_DSN="host=localhost;database=test;user=test;password=test" pytest
Ohne gesetzte DSN-Umgebungsvariable werden die Postgres-/MySQL-Tests übersprungen.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dialectorm_m1kad0-0.1.1.tar.gz.
File metadata
- Download URL: dialectorm_m1kad0-0.1.1.tar.gz
- Upload date:
- Size: 12.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
329469aad1852ddc6242ca643b9c81000ccc5ffe32bb6f548c346907bdad82ec
|
|
| MD5 |
4f28450b370af5cacc4bdc4a0bfd267d
|
|
| BLAKE2b-256 |
0dd1d3ba7c83cef1018dcff5ea2a5a0307b9f3cfa6bf30858bebc5c4718cdea1
|
File details
Details for the file dialectorm_m1kad0-0.1.1-py3-none-any.whl.
File metadata
- Download URL: dialectorm_m1kad0-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da68c247f8812f74912e62d77184387dbdd6961c0ef7ec9671099a3bf8d1420a
|
|
| MD5 |
e2e14e5afd3d94a117a8fb34e13b4797
|
|
| BLAKE2b-256 |
78c126ba7d59611d343617b14cc6ba36ebe546e5c8503e5cc3aebb1774b9209f
|