Add create database function in console interface
Refactor database code