2. How to create/setup user

To run PAL functions

What is PAL? Predictive Analysis Library. We take all algrithms from there.

If user exists

Run these sql commands to grant him role
Details here
and here
[ ]:
GRANT "AFL__SYS_AFL_AFLPAL_EXECUTE" TO <USER>;
GRANT "AFL__SYS_AFL_AFLPAL_EXECUTE_WITH_GRANT_OPTION" TO <USER>;*

Example:
GRANT "AFL__SYS_AFL_AFLPAL_EXECUTE" TO DEVELOPER;
GRANT "AFL__SYS_AFL_AFLPAL_EXECUTE_WITH_GRANT_OPTION" TO DEVELOPER;
Note that commands above work only if PAL is installed on your system. How to check it? Run these SQL commands to check. If there aren’t any errors, everything is OK.
Details here
[ ]:
SELECT * FROM "SYS"."AFL_AREAS" WHERE AREA_NAME = 'AFLPAL';
SELECT * FROM "SYS"."AFL_PACKAGES" WHERE AREA_NAME = 'AFLPAL';
SELECT * FROM "SYS"."AFL_FUNCTIONS" WHERE AREA_NAME = 'AFLPAL';

If user doesn’t exist/doesn’t have role

You can run our script that will setup everything for you.

[ ]:
from hana_automl.utils.scripts import setup_user
from hana_ml.dataframe import ConnectionContext
[10]:
# Create a connection to database (replace it with your credentials)
# NOTE: you need to be logged in as user where PAL is installed!

cc = ConnectionContext(address='address', user='user', password='password', port=39015)
[11]:
# Replace PAL_USER and password with any username you want, it's just an example
# NOTE: if user exists, it will be assigned a role to run PAL.
# Otherwise, a new user with provided password will be created

setup_user(connection_context=cc, username='PAL_USER', password="PAL_USER's password")
Checking that PAL is installed...
AFL_AREAS True
AFL_PACKAGES True
AFL_FUNCTIONS True
Checking if user exists...
User PAL_USER does not exist, creating new user with default password "newUser1533HelloWorld"...
Done
Changing PAL_USER's password to yours...
Done
Granting roles to PAL_USER to execute PAL functions...
Done.
[12]:
# Recreate a connection to test if we can use library with this user. Note that PAL_USER is just an example,
# Replace it with credentials from 'setup_user' function

cc = ConnectionContext(address='address', user='PAL_USER', password="PAL_USER's password", port=39015)