Use ORM and reduce the number of sqlite calls to get local users

Ticket:	#5602