davidhamann / python-fmrest

Python wrapper around the FileMaker Data API
MIT License
100 stars 27 forks source link

Add examples for new perform_script method #9

Open davidhamann opened 5 years ago

davidhamann commented 5 years ago

Current examples only show FMSv17 style of executing scripts.

TODO: Update examples.

nexgen commented 4 years ago

Any update on this? Looking for example performing script.

davidhamann commented 4 years ago

Sorry, very busy lately and no time to spend on the docs. The code itself has lots of comments that could help in figuring out how to use it (find perform_script in fmrest/server.py and tests in tests/integration/test_server.py).

This would be a full example on how to perform a script using the new script route:

import fmrest

server = fmrest.Server(url=URL,
    user=ACCOUNT_NAME,
    password=ACCOUNT_PASS,
    database=DATABASE,
    layout=LAYOUT
)

with server as fms:
    fms.login()
    result = fms.perform_script('script-name', 'script-param')

result would then contain a tuple of error (0 for success) and the return value of the script.

You can also always access the last result via the last_script_result property, so in this case (fms.last_script_result).

Hope this gets you started. Feel free to ask again if you experience any issues.