ORM Query refactoring access.py

One query instead of two queries to database.