I'm assuming your script was intentionally incomplete as you didn't close the try block.
Also, I'd check the hostProps.get("databasexyz") statement. That one looks for a property on the device in LM called "databasexyz". That likely is the actual value, not the value of the property with that name. So you might change it to:
dbname = hostProps.get("database_name")
Then, in LM, you'd create a property on the device called "dbname" and give it the value of "databasexyz". You might consider making dbname part of the AppliesTo, since this whole script will fail if the device doesn't have that property.