I have a Python CLI program, with SQL database models and want to add a frontend with a MVC framework (such as Django). What's the best way to interface my program with the framework, if I've already defined my models?
Do I either:
- Rewrite the model so it's shared by both Django and my program
- Write a layer that interfaces between Django and my Program
- Remove the model from My Program and let Django handle it
Choice #1: Shared Model
My Program / | \ Binaries Model Classes | Django / \ View Controller
Choice #2: Create a Bridging Library
My Program / | \ Binaries Model Classes | My-Bridge | Django / | \ View Model Controller
Choice #3: Use Django for Most Work and Remove Model from My Program
Classes \ My Program / | Binaries | | My-Bridge | Django / | \ View Model Controller
I'm avoiding Choice #1 (Create a Shared Model) because I don't know how to create a shared model using Django's ORM and SQLAlchemy.
I'm unsure about Choice #2 (Creating a Bridge) because I don't know if this uses Django to its full extent. From the documentation, it seems as thought Django should handle the Model, given that its a MVC framework.
I'm also avoiding Choice #3 (Removing the Model from Program) because I would have to re-write all the SQLAlchemy ORM logic that uses the SQLAlchemy model in My-Program.
What do you guys think? Which choice is best given that I've already written the CLI version of my program?