fm.executesql (expression, values=None)

Parameters:
   expression: FileMaker SQL statements
   values: one or more values to use as SQL parameters

Result:
   text version of SQL result

Error:
   Python exception
Script Step:
   N/A

––––––––––

First appeared in: 

Examples in demo file: 2

Compatibility:   Client, macOS, Server, Ubuntu, WebDirect

––––––––––

An import fm statement is needed in your Python script before using this method.

This Python function calls back to the FileMaker database engine to evaluate your SQL expression, and returns a Python list object with the results.

For example, we can execute this in Python:

r = fm.executesql ("SELECT id,name FROM EXAMPLE")

and get back a result like this:

((95.0, 'last went to sleep'), (90.0, 'calendar for year'))

The optional values parameter is a list of one or values that will be used as SQL parameters. Here we’ll create a new record in the SCRATCH table with the values from the Python variables id and filename:

fm.executesql ('INSERT INTO "SCRATCH" (text_1, text_2) VALUES (?,?)', [id, filename])

If there is a Python exception, and the call is not inside a try/catch block, the Python script halts and an error is returned by bBox_LastError.