Added database support

Added some database support, it needs some addition and bug fixes
probably but it's a start.