simplified python code to pass db object instead of host, dbname, user, password