Remove code duplication Part 2

Remove code duplication from impl_mongodb and impl_db2 as both of
these drivers use pymongo. This is a multiple step process as there
are several differences between the implementation of these drivers.

The second step is about to move the query related functions into
pymongo_base.

Change-Id: I1d3ce36a9189e1773ef44578e990429ace64792a
Merge "Remove code duplication Part 2"