sdb module: add backward-compatible support for Python 3.3+

test_db.py doesn't work for currently code already, and I fear it would be a big job to fix it...

All integration tests passed.
Same here - another candidate for adding to `compat.py` instead of having this logic in multiple places. Maybe a `long_type` or something similar to how there is a `text_type`?