Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/klen/pypika-orm
Async ORM based on PyPika
https://github.com/klen/pypika-orm
asyncio orm pypika sql
Last synced: 17 days ago
JSON representation
Async ORM based on PyPika
- Host: GitHub
- URL: https://github.com/klen/pypika-orm
- Owner: klen
- Created: 2021-08-25T10:25:29.000Z (over 3 years ago)
- Default Branch: develop
- Last Pushed: 2021-09-09T08:05:58.000Z (over 3 years ago)
- Last Synced: 2024-11-01T06:13:23.853Z (2 months ago)
- Topics: asyncio, orm, pypika, sql
- Language: Python
- Homepage:
- Size: 42 KB
- Stars: 9
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PyPika-ORM - ORM for PyPika SQL Query Builder
The package gives you ORM for [PyPika](https://github.com/kayak/pypika) with
asycio support for a range of databases (SQLite, PostgreSQL, MySQL).[![Tests Status](https://github.com/klen/pypika-orm/workflows/tests/badge.svg)](https://github.com/klen/pypika-orm/actions)
[![PYPI Version](https://img.shields.io/pypi/v/pypika-orm)](https://pypi.org/project/pypika-orm/)
[![Python Versions](https://img.shields.io/pypi/pyversions/pypika-orm)](https://pypi.org/project/pypika-orm/)## 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:
```shell
$ pip install pypika-orm
```You can install the required database drivers with:
```shell
$ pip install pypika-orm[sqlite]
$ pip install pypika-orm[postgresql]
$ pip install pypika-orm[mysql]
```## Usage
```python
from pypika_orm import Model, fieldsclass 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()
await manager(User).create_table().if_not_exists()await manager(Role).insert(name='user')
await manager(User).insert(name='jim', role_id=1)[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/pypika-orm/issues## Contributing
Development of the project happens at: https://github.com/klen/pypika-orm
## License
Licensed under a [MIT License](http://opensource.org/licenses/MIT)