forked from s_ranjbar/city_retrofit
Persistence up and running with small fix
This commit is contained in:
parent
f99b8497ff
commit
a34206e6ff
|
@ -43,7 +43,6 @@ class Application(Repository):
|
|||
try:
|
||||
application = Model(name=name, description=description, application_uuid=application_uuid)
|
||||
self.session.add(application)
|
||||
self.session.flush()
|
||||
self.session.commit()
|
||||
return application
|
||||
except SQLAlchemyError as err:
|
||||
|
@ -76,20 +75,24 @@ class Application(Repository):
|
|||
"""
|
||||
try:
|
||||
self.session.query(Model).filter(Model.application_uuid == application_uuid).delete()
|
||||
self.session.flush()
|
||||
self.session.commit()
|
||||
except SQLAlchemyError as err:
|
||||
logger.error(f'Error while deleting application: {err}')
|
||||
|
||||
def get_by_uuid(self, application_uuid: str) -> Model:
|
||||
def get_by_uuid(self, application_uuid: str) -> Union[Model, None]:
|
||||
"""
|
||||
Fetch Application based on the application uuid
|
||||
:param application_uuid: the application uuid
|
||||
:return: Application with the provided application_uuid
|
||||
:return: Application with the provided application_uuid or None
|
||||
"""
|
||||
try:
|
||||
return self.session.execute(select(Model).where(
|
||||
result_set = self.session.execute(select(Model).where(
|
||||
Model.application_uuid == application_uuid)
|
||||
).first()[0]
|
||||
).first()
|
||||
if result_set is None:
|
||||
return None
|
||||
return result_set[0]
|
||||
except SQLAlchemyError as err:
|
||||
logger.error(f'Error while fetching application by application_uuid: {err}')
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
xmltodict
|
||||
numpy
|
||||
trimesh
|
||||
trimesh[all]==3.12.0
|
||||
pyproj
|
||||
pandas
|
||||
requests
|
||||
|
|
Loading…
Reference in New Issue
Block a user