PY: generate foreign key query in ORAL.