demo.py : a small sample application example use:
PYTHONPATH=$PWD python3 examples/demo.py 10.0.0.9
demo_relationship.py : an extension of the demo.py to demonstrate relationship functionality
It is possible to expose existing databases, as an example I implemented the employees and sakila MuySQL test databases with safrs.
For this to work, I used a modified sqlacodegen to generate the sqlalchemy models sakila.py and employees.py .
The Flask webservices are created with expose_sakila.py and expose_employees.py. They can be started as usual:
$ python3 examples/expose_employees.py 172.1.1.2 5000
Exposed sakila database:
Unfortunatley, the code generated with sqlacodegen needed some manual changes before it was usable. For example, the declarative column types for INTEGER and SMALLINT didn't work so I had to create small wrappers to fix this:
def SMALLINT(_):
return db.SMALLINT
def INTEGER(_):
return db.INTEGER
You may run into similar problems trying to expose other schemas. These problems may be hard to solve if you're unfamiliar with SQLAlchemy. Feel free to open a github issue and I'll try to help you out.