Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Python
Posted by: nawaf alansari
Added: Oct 9, 2021 11:27 PM
Modified: Oct 9, 2021 11:34 PM
Views: 264
Tags: sqlalchemy
  1. class SqlAlchemyRepository(AbstractRepository):
  2.     def __init__(self, session):
  3.         self.session = session
  4.  
  5.     def add(self, batch):
  6.         self.session.add(batch)
  7.  
  8.     def get(self, reference):
  9.         return self.session.query(Batch).filter_by(reference=reference).one()
  10.  
  11.     def list(self):
  12.         return self.session.query(Batch).all()