Avoid connecting to central database when not necessary

When using SQLite, this fails entirely. But it's a good idea for all
databases.

Bug: 54078
Change-Id: I2cc2e57d812fe87ffc227477425029c1e9b15543
Merge "Avoid connecting to central database when not necessary"