fm.executesql (expression, values=None)

Parameters:
   expression: FileMaker SQL statements

   values: one or more values to use as SQL parameters


Result:
   text, number or JavaScript array of SQL result


Error:
   JavaScript 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 JavaScript function calls back to the FileMaker database engine to evaluate your SQL expression, and returns a JavaScript string or array 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])

Not currently supported on Ubuntu.