added device insert/update SQL
auto-convert DB type keys to uppercase
refactoring to allow for single device retrieval