db operation implementation in python