script to query all databases