Update db_to_data.py

+ fixed minor bugs