semvec/pypi-packages huggingface dataset:
nameko-pony 1.3.1
Pony dependency for nameko services
License: Apache License, Version 2.0

# nameko-pony

Pony dependency for nameko services

## Installation
```
pip install nameko-pony
```

## Usage
app.py
```python
from nameko.rpc import rpc
from pony.orm import Database, Required
from nameko_pony import PonySession

db = Database()


class Person(db.Entity):
    name = Required(str)


class FooService(object):
    name = 'foo_service'

    db_session = PonySession(db)

    @rpc
    @db_session
    def hello(self):
        Person(name='hello')
        Person(name='world')

    @rpc
    def world(self):
        with self.db_session:
            return [p.name for p in Person.select()]
```

config.yml
```yml
AMQP_URI: 'pyamqp://guest:guest@localhost'
DATABASE_URI: 'sqlite:///:memory:'
# DATABASE_URI: 'mysql://usr:pwd@localhost/db_name'
```