Async ORM based on PyPika
Project description
PyPika-ORM - ORM for PyPika SQL Query Builder
The package gives you ORM for PyPika with asycio support for a range of databases (SQLite, PostgreSQL, MySQL).
Warning
The project is in early pre-alpha state and not ready for production
Requirements
- python >= 3.7
Installation
pypyka-orm should be installed using pip:
$ pip install pypika-orm
You can install the required database drivers with:
$ pip install pypika-orm[sqlite]
$ pip install pypika-orm[postgresql]
$ pip install pypika-orm[mysql]
Usage
from pypika_orm import Model, fields
class Role(Model):
id = fields.Auto()
name = fields.Varchar(max_length=100, default='user')
class User(Model):
id = fields.Auto()
name = fields.Varchar()
is_active = fields.Bool(default=True, null=False)
role_id = fields.ForeignKey(Role.id)
from pypika_orm import Manager
async with Manager('sqlite:///:memory:') as manager:
await manager(Role).create_table().if_not_exists().execute()
await manager(User).create_table().if_not_exists().execute()
await manager(Role).insert(name='user').execute()
await manager(User).insert(name='jim', role_id=1).execute()
[user] = await manager(User).select().fetchall()
assert user
Bug tracker
If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/aio-databases/issues
Contributing
Development of the project happens at: https://github.com/klen/aio-databases
License
Licensed under a MIT License
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
File details
Details for the file pypika-orm-0.0.10.tar.gz
.
File metadata
- Download URL: pypika-orm-0.0.10.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34d9f8ecf71b13322ffef0d895f44d234522d619fe18d5bb91bf52a055c62f0b |
|
MD5 | 610d1461fbdfb1257f709df00f38eb51 |
|
BLAKE2b-256 | c4326f66b5294f1721020d9a97c8a8badf3a328b0b46b8e844281e812c01adfd |
File details
Details for the file pypika_orm-0.0.10-py3-none-any.whl
.
File metadata
- Download URL: pypika_orm-0.0.10-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e359990b9cc97b95fc71c3c9b5c7a4bbe9a2a68ad461552063a47b12c1b9bffa |
|
MD5 | 3661991a7a3983d41a3d10e6f1072775 |
|
BLAKE2b-256 | 91b6678250536df875fc60f492fb517f1f4623a8e8494e9b092308bc6d2ff6de |