Pyorient batch not working

pyorient.exceptions.PyOrientCommandException: com.orientechnologies.orient.core.exception.OCommandExecutionException - Invalid script:Encountered " <LET> "let "" at line 1, column 163.
Was expecting one of:
    <WHILE> ...
    <IF> ...
    <FOREACH> ...
    ";" ...
    <IF> ...

My batch command is as follows:

batch_commands = ['begin;']

for index, row in tech_server_edges.iterrows():
    if index > 0:
        break;
    print(row['subcategory'])
    command = (
        "let A = select from software_subcategory where name = '%s';"
        "let B = select from software where name = '%s' AND version = '%s';"
        "let C = CREATE EDGE contains from $A to $B SET segmentId = 'PADU' "
        ", domain='PADU', modifiedByProcess='PADU'; return $C;" % (row['subcategory'], row['name'], row['version'])
    )
    batch_commands.append(command)

batch_commands.append('commit retry 100;')
cmd = ''.join(batch_commands)
print(cmd)
results = orient_client.batch(cmd)

the exact query is:
begin;let A = select from software_subcategory where name = 'uncategorized';let B = select from software where name = 'SIC' AND version = '3.7';let C = CREATE EDGE contains from $A to $B SET segmentId = 'PADU' , domain='PADU', modifiedByProcess='PADU'; return $C;commit retry 100;

I’m not sure what I’m doing wrong. I was under the impression I could create an edge like this via pyorient.

Hey, if you’re reading this and having similar issues, I wanted to point out that I found the reason on this blog post it doesn’t seem to be documented anywhere that I need to have each batch command on a new line. I managed to make it work this time.

EDIT: I think it was the actual name of the edge that was the issue. It seems contains might be a reserved word?