This release is a pre-release and may not be stable for production use.
apgorm
An asynchronous ORM wrapped around asyncpg. Examples can be found under examples/. Run examples with python -m examples.<example_name> (python -m examples.basic).
Please note that this library is not for those learning SQL or Postgres. Although the basic usage of apgorm is straightforward, you will run into problems, especially with migrations, if you don't understand regular SQL well.
Features
- Fairly straightforward and easy-to-use.
- Support for basic migrations.
- Protects against SQL-injection.
- Python-side converters and validators.
- Decent many-to-many support.
- Fully type-checked.
- Tested.
Limitations
- Limited column namespace. For example, you cannot have a column named
tablenamesince that is used to store the name of the model. - Only supports PostgreSQL with asyncpg.
- Migrations don't natively support field/table renaming or type changes, but you can still write your own migration with raw SQL.
- Converters only work on instances of models and when initializing the model.
- Models can only detect assignments. If
User.nicknamesis a list of nicknames, it won't detectuser.nicknames.append("new nick"). You need to douser.nicknames = user.nicknames + ["new nick"].
Basic Usage
Defining a model and database:
class User(apgorm.Model):
username = apgorm.types.VarChar(32).field()
email = apgorm.types.VarChar().nullablefield()
primary_key = (username,)
class Database(apgorm.Database):
users = User
Intializing the database:
db = Database(migrations_folder="path/to/migrations")
await db.connect(database="database name")
Creating & Applying migrations:
if db.must_create_migrations():
db.create_migrations()
if await db.must_apply_migrations():
await db.apply_migrations()
Basic create, fetch, update, and delete:
user = await User(username="Circuit").create()
print("Created user", user)
assert user == await User.fetch(username="Circuit")
user.email = "email@example.com"
await user.save()
await user.delete()
Metadata
Release files for apgorm 1.0.0b14
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 |
|---|---|---|---|---|
| apgorm-1.0.0b14.tar.gz | 32.3 kB | Without provenance | Details for apgorm-1.0.0b14.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| apgorm-1.0.0b14-py3-none-any.whl | Python 3 | none | any | Details for apgorm-1.0.0b14-py3-none-any.whl |
Total release size: 79.1 kB
Release files / apgorm-1.0.0b14.tar.gz
| Download URL | apgorm-1.0.0b14.tar.gz |
|---|---|
| Size | 32.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5fa4ede90b97c11bd59a36c198d6f5df0efbbc25695d88a89bd05c5ec65da214
|
|
BLAKE2b-256 checksum How to use checksums |
d30654c6c95a62d52d7305ac963d74e03a53854ba0e4fc884c0054334a495c5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.8.14 Linux/5.15.0-1022-azure
|
Release files / apgorm-1.0.0b14-py3-none-any.whl
| Download URL | apgorm-1.0.0b14-py3-none-any.whl |
|---|---|
| Size | 46.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3086b04ff8e99342932b09856007d94ead4f46f025ae4a74ee01fcfcbb260c98
|
|
BLAKE2b-256 checksum How to use checksums |
175534f2162f2d16e247d530eb41fcc300c8109fdbf5ae253ae7f8b1a7578eff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.8.14 Linux/5.15.0-1022-azure
|
Security for apgorm 1.0.0b14
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.