Created
          July 19, 2014 20:50 
        
      - 
      
 - 
        
Save kennyledet/a6281d5ea70c50b5e731 to your computer and use it in GitHub Desktop.  
    SQLAlchemy Duplicate Row
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def copy_row(model, row, ignored_columns=[]): | |
| copy = model() | |
| for col in row.__table__.columns: | |
| if col.name not in ignored_columns: | |
| try: | |
| copy.__setattr__(col.name, getattr(row, col.name)) | |
| except Exception as e: | |
| print e | |
| continue | |
| return copy | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Simpler without passing model in argument :