some to_python and db_type logic