database.py: Optimizes one query away when adding URLs.

Gets the URL string ID before and uses that for comparison.