Hi,

I was wondering if I can get some pointers on how to do this. I want to 
copy data to an archive table before deleting the data. So let's say I have 
a model like below

class ModelA(...):
   id = db.Column(db.Integer, primary_key=True)
   fake_model_id = db.Column(db.Integer,db.ForeignKey('some_fake_model.id'))
   ...

   fake = db.relationship('SomeFakeModel')
   ...

For the archived class, do I need to include the relationship? The reason I 
ask is because I'm not sure how the relationship is populated via 
sqlalchemy.

So for the use case:
   1. delete ModelA
   2. restore ModelA

class ArchivedModelA(...):
   id = db.Column(db.Integer, primary_key=True)
   fake_model_id = db.Column(db.Integer,db.ForeignKey('some_fake_model.id'))
   ...
   # no relationship here - is it needed?
   ...

To restore ModelA, I'd copy ArchivedModelA attributes to ModelA 
(e.g https://stackoverflow.com/a/36225970) - but if ArchivedModelA doesn't 
have the "fake" relationship, is the new restored ModelA going to have the 
fake relationship via the foreign key? The 
.columns.keys()
 doesn't return the relationship.

Hope what I wrote makes sense!

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/71fd3daa-001b-4359-915b-d4156ed21878%40googlegroups.com.

Reply via email to