Here are the examples of the python api sqlalchemy.exc.SQLAlchemyError taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
45 Examples
3
View Complete Implementation : appointment_detail.py
Copyright Apache License 2.0
Author : bcgov
Copyright Apache License 2.0
Author : bcgov
@oidc.accept_token(require_token=True)
def get(self, id):
csr = CSR.find_by_username(g.oidc_token_info['username'])
try:
appointment = Appointment.query.filter_by(appointment_id=id)\
.filter_by(office_id=csr.office_id)\
.first_or_404()
result = self.appointment_schema.dump(appointment)
return {"appointment": result.data,
"errors": result.errors}, 200
except exc.SQLAlchemyError as error:
logging.error(error, exc_info=True)
return {"message": "API is down"}, 500
3
View Complete Implementation : appointment_list.py
Copyright Apache License 2.0
Author : bcgov
Copyright Apache License 2.0
Author : bcgov
@oidc.accept_token(require_token=True)
def get(self):
csr = CSR.find_by_username(g.oidc_token_info['username'])
try:
appointments = Appointment.query.filter_by(office_id=csr.office_id).all()
result = self.appointment_schema.dump(appointments)
return {"appointments": result.data,
"errors": result.errors}, 200
except exc.SQLAlchemyError as error:
logging.error(error, exc_info=True)
return {"message": "API is down"}, 500
3
View Complete Implementation : booking_detail.py
Copyright Apache License 2.0
Author : bcgov
Copyright Apache License 2.0
Author : bcgov
@oidc.accept_token(require_token=True)
def get(self, id):
csr = CSR.find_by_username(g.oidc_token_info['username'])
try:
booking = Booking.query.filter_by(booking_id=id).first_or_404()
# Also 404 the request if they shouldn't be able to see this booking
if booking.office_id != csr.office_id and csr.liaison_designate != 1:
abort(404)
result = self.booking_schema.dump(booking)
return {"booking": result.data,
"errors": result.errors}, 200
except exc.SQLAlchemyError as error:
logging.error(error, exc_info=True)
return {"message": "API is down"}, 500
3
View Complete Implementation : booking_list.py
Copyright Apache License 2.0
Author : bcgov
Copyright Apache License 2.0
Author : bcgov
@oidc.accept_token(require_token=True)
def get(self):
csr = CSR.find_by_username(g.oidc_token_info['username'])
office_filter = csr.office_id
if request.args.get('office_id') and csr.liaison_designate == 1:
office_filter = request.args.get('office_id')
try:
bookings = Booking.query.filter_by(office_id=office_filter).all()
result = self.booking_schema.dump(bookings)
return {'bookings': result.data,
'errors': result.errors}, 200
except exc.SQLAlchemyError as error:
logging.error(error, exc_info=True)
return {"message": "API is down"}, 500
3
View Complete Implementation : exam_detail.py
Copyright Apache License 2.0
Author : bcgov
Copyright Apache License 2.0
Author : bcgov
@oidc.accept_token(require_token=True)
def get(self, id):
csr = CSR.find_by_username(g.oidc_token_info['username'])
try:
exam = Exam.query.filter_by(exam_id=id).first()
if not (exam.office_id == csr.office_id or csr.liaison_designate == 1):
return {"The Exam Office ID and CSR Office ID do not match!"}, 403
result = self.exam_schema.dump(exam)
return {'exam': result.data,
'errors': result.errors}, 200
except exc.SQLAlchemyError as error:
logging.error(error, exc_info=True)
return {'message': 'API is down'}, 500
3
View Complete Implementation : exam_event_id_detail.py
Copyright Apache License 2.0
Author : bcgov
Copyright Apache License 2.0
Author : bcgov
@oidc.accept_token(require_token=True)
def get(self, id):
try:
exam = Exam.query.filter_by(event_id=str(id)).all()
if not exam:
return {'message': False}, 200
else:
return {'message': True}, 200
except exc.SQLAlchemyError as error:
logging.error(error, exc_info=True)
return {"message": "API is down"}, 500
3
View Complete Implementation : exam_type_list.py
Copyright Apache License 2.0
Author : bcgov
Copyright Apache License 2.0
Author : bcgov
@oidc.accept_token(require_token=True)
def get(self):
try:
exam_types = ExamType.query.all()
result = self.exam_type_schema.dump(exam_types)
return {'exam_types': result.data,
'errors': result.errors }, 200
except exc.SQLAlchemyError as error:
logging.error(error, exc_info=True)
return {'message': 'API is down'}, 500
3
View Complete Implementation : invigilator_list.py
Copyright Apache License 2.0
Author : bcgov
Copyright Apache License 2.0
Author : bcgov
@oidc.accept_token(require_token=True)
def get(self):
csr = CSR.find_by_username(g.oidc_token_info['username'])
try:
invigilators = Invigilator.query.filter_by(office_id=csr.office_id)\
.filter(Invigilator.deleted.is_(None))
result = self.invigilator_schema.dump(invigilators)
return {'invigilators': result.data,
'errors': result.errors}, 200
except exc.SQLAlchemyError as error:
logging.error(error, exc_info=True)
return {"message": "api is down"}, 500
3
View Complete Implementation : room_list.py
Copyright Apache License 2.0
Author : bcgov
Copyright Apache License 2.0
Author : bcgov
@oidc.accept_token(require_token=True)
def get(self):
csr = CSR.find_by_username(g.oidc_token_info['username'])
try:
rooms = Room.query.filter_by(office_id=csr.office_id)\
.filter(Room.deleted.is_(None))
result = self.rooms_schema.dump(rooms)
return {'rooms': result.data,
'errors': result.errors}, 200
except exc.SQLAlchemyError as error:
logging.error(error, exc_info=True)
return {"message": "api is down"}, 500
3
View Complete Implementation : categories.py
Copyright Apache License 2.0
Author : bcgov
Copyright Apache License 2.0
Author : bcgov
@oidc.accept_token(require_token=True)
def get(self):
try:
services = Service.query.filter_by(actual_service_ind=0).order_by(Service.service_name).all()
result = self.categories_schema.dump(services)
return {'categories': result.data,
'errors': result.errors}, 200
except exc.SQLAlchemyError as e:
print(e)
return {"message": "API is down"}, 500