Posts

Showing posts with the label CRUB

Using SQLAlchemy and Django FormSet to work with an external database

Manipulating an external database with SQLAlchemy and Django FormSet is not as easy as Form ( http://iambusychangingtheworld.blogspot.com/2013/07/django-make-use-of-django-forms.html ). It's even more complicated when you want to do the CRUD. I had to do some hacks to achieve that. For example, I have an external database table as following: merge table: ======================= || id  || original     || translated     || ======================= || 1   || course123 || courseABC || || 2   || course456 || courseABC || || 3   || course234 || courseABC || || ...  || ...              || ...                 || ======================= 1. First, define the merge table model with SQLAlchemy ( MyProject.utils.merge_models ): class Merge (Base): __tablename__ = 'merge' id = Column(Integer, primary_key=True) original = Column(String(100)) translated = Co...