Check if database is opened before submit command