From Rekall 2.3.4, there is a shortcut to getting a cursor. You can simply write code like (in this example, in the event function for a button onclick event):
def eventFunc (button) : cursor = button.cursor() cursor.execute ('select .....', [ arg1, ... ]) .... |
This code will return a cursor which accesses the database from which the form containing the button was loaded - which will be what you usually want to do. In fact, you can do this even more quickly:
def eventFunc (button) : cursor = button.cursor('select .....', [ arg1, ... ]) .... |
In this case, the cursor is allocated and executed, so on return it is immediately ready to retrieve values. The parameter list is optional, and can be omitted if the query has no place holders.
Following this line a little futher, if myfield is a field in the form, we can write the code below. This is a little hack that works with all data controls. The setValueFromQuery method takes an optional parameter list as above. There is also an optional row argument if you want to set the value in a row other than the current one.
def eventFunc (button) : button.__parent__.myfield.setValueFromQuery ('select name from t where id = 42') |
These shortcuts work via the python scripting interfaces extension mechanism. The implementation code is actuall written in python and is dynamically attached to the python objects that represent controls as they are created. These methods are documented along with the other control methods.