Rework `dbopen` modes

Whilst previously the `mode` argument passed to `_dbopen` was a plain
`int`, without the predefined flag values being exposed, this change
reworks this into using a list of a flag type.