How to effectively work with Databases in Python