cache.py: Fixes __iter__().
database.py: Uses SQLAlchemy core for bulk insert. Adds caching for IDs.