I want to make a connection to a database. Depending on the computer the script is running it should be a remote connection (windows computer) or a direct connection (raspberry pi).
I'm using the script below but I think there should be a much nicer way to do this (no try except). I'm using the try except because os.environ on windows and raspberry pi doesn't have an identical ID.
import os
try:
if os.environ['USERDOMAIN'] == 'DESKTOP-name':
print('Make windows conncetion')
except:
if os.environ['HOSTNAME'] == 'raspberrypi':
print('Make raspberry connection')