mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 07:21:13 -05:00
24 lines
475 B
Python
24 lines
475 B
Python
from sqlalchemy.exc import SQLAlchemyError
|
|
|
|
from app import db
|
|
|
|
|
|
# Should I use SQLAlchemyError?
|
|
class DAOException(SQLAlchemyError):
|
|
pass
|
|
|
|
|
|
class DAOClass(object):
|
|
class Meta:
|
|
model = None
|
|
|
|
def create_instance(self, inst, _commit=True):
|
|
db.session.add(inst)
|
|
if _commit:
|
|
db.session.commit()
|
|
|
|
def delete_instance(self, inst, _commit=True):
|
|
db.session.delete(inst)
|
|
if _commit:
|
|
db.session.commit()
|