This data structure is getting a bit complex. It might be worthwhile entertaining a wrapper object that holds the repo ID, DB, and protocol (and anything else that's needed in the future) and returning a list of those. It would remove the need to check this code to find the proper key to look up. An added benefit of that is the __del__ could be used to ensure the database connection is closed (admittedly, I'm not sure why the prospect of them not being closed scares me like it does).

I am naive to the full usage of these, however, and there may be look ups by repo ID which make the higher level dict more desirable than a list of objects.