# Sanic-PW
A port of the [Flask-PW](https://github.com/klen/flask-pw) package for [Sanic framework](https://github.com/channelcat/sanic).
# Features
- Configuring Peewee ORM like in Flask with SQLAlchemy
- Migrate commands (create, rollback, etc.) via:
- using commands as a part of Sanic-Script
- click CLI
- Pre- and post-signals support for saving and deleting
# Requirements
- Python 3.6+ (older not tested)
# Dependency note
For using the 2nd version of Peewee ORM, please use `sanic-pw==0.1.0`.
# Using
## Installing
For installing Sanic-PW use the following command:
```
pip install sanic-pw
```
## List of available settings
| Config parameter | Description | Default value |
|------------------|-------------|----------------|
| PEEWEE_DATABASE_URI | A connection URI | `'sqlite:///peewee.sqlite'` |
| PEEWEE_CONNECTION_PARAMS | Connection parameters for Peewee ORM | `{}` |
| PEEWEE_MIGRATE_DIR | Path to directory with migrations | `'migrations'` |
| PEEWEE_MIGRATE_TABLE | Name of database table with migrations | `'migratehistory'` |
| PEEWEE_MODELS_MODULE | Path to module which contains you applications' Models | `''` |
| PEEWEE_MODELS_IGNORE | Models which should be ignored in migrations | `[]` |
| PEEWEE_MODELS_CLASS | Base models class | `<sanic_pw.Model>` |
| PEEWEE_MANUAL | Don't connect to db when request starts and close when it ends automatically | `False` |
| PEEWEE_USE_READ_SLAVES | Use database slaves for reading data when coming `SELECT ...` queries | `True` |
| PEEWEE_READ_SLAVES | A list of nodes which can be used for reading | `[]` |
## Migrations
If you're using the Sanic-Script package, then append a new command to your manager:
```python
from sanic_pw import Peewee
# ...
app.db = Peewee(app)
manager = Manager(app)
manager.add_command('db', app.db.manager)
```
For a case when you're prefer to use click it almost the same:
```python
from sanic_pw import Peewee
# ...
app.db = Peewee(app)
app.db.cli()
```
After it, you can use database `create`, `migrate` or `rollback` commands.
A port of the [Flask-PW](https://github.com/klen/flask-pw) package for [Sanic framework](https://github.com/channelcat/sanic).
# Features
- Configuring Peewee ORM like in Flask with SQLAlchemy
- Migrate commands (create, rollback, etc.) via:
- using commands as a part of Sanic-Script
- click CLI
- Pre- and post-signals support for saving and deleting
# Requirements
- Python 3.6+ (older not tested)
# Dependency note
For using the 2nd version of Peewee ORM, please use `sanic-pw==0.1.0`.
# Using
## Installing
For installing Sanic-PW use the following command:
```
pip install sanic-pw
```
## List of available settings
| Config parameter | Description | Default value |
|------------------|-------------|----------------|
| PEEWEE_DATABASE_URI | A connection URI | `'sqlite:///peewee.sqlite'` |
| PEEWEE_CONNECTION_PARAMS | Connection parameters for Peewee ORM | `{}` |
| PEEWEE_MIGRATE_DIR | Path to directory with migrations | `'migrations'` |
| PEEWEE_MIGRATE_TABLE | Name of database table with migrations | `'migratehistory'` |
| PEEWEE_MODELS_MODULE | Path to module which contains you applications' Models | `''` |
| PEEWEE_MODELS_IGNORE | Models which should be ignored in migrations | `[]` |
| PEEWEE_MODELS_CLASS | Base models class | `<sanic_pw.Model>` |
| PEEWEE_MANUAL | Don't connect to db when request starts and close when it ends automatically | `False` |
| PEEWEE_USE_READ_SLAVES | Use database slaves for reading data when coming `SELECT ...` queries | `True` |
| PEEWEE_READ_SLAVES | A list of nodes which can be used for reading | `[]` |
## Migrations
If you're using the Sanic-Script package, then append a new command to your manager:
```python
from sanic_pw import Peewee
# ...
app.db = Peewee(app)
manager = Manager(app)
manager.add_command('db', app.db.manager)
```
For a case when you're prefer to use click it almost the same:
```python
from sanic_pw import Peewee
# ...
app.db = Peewee(app)
app.db.cli()
```
After it, you can use database `create`, `migrate` or `rollback` commands.
Metadata
Release files for sanic-pw 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sanic-pw-0.2.0.tar.gz | 5.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sanic_pw-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.1 kB
Release files / sanic-pw-0.2.0.tar.gz
| Download URL | sanic-pw-0.2.0.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c33c7091970d48549c07abdefa134b1b019df388cc76f76e19215251cdc1146
|
|
BLAKE2b-256 checksum How to use checksums |
0899f5124955f5292e32acfab26e4e59befa989be756d7332c162d70d2ab1168
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / sanic_pw-0.2.0-py3-none-any.whl
| Download URL | sanic_pw-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7d76fa19fe6a2dc1b3908b343a92af234bbbee6ccb2653078ffc4426c3282720
|
|
BLAKE2b-256 checksum How to use checksums |
f38df136c2e5ccc635dca61ca2a5602d8e21a4b670f088a9c582ce425a11998f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |