Jump to content

Creating many objects


peter divers

Recommended Posts

Posted

Hello im passing in a spreadsheet into python trying to create many asset builds and folder etc. from this and i keep getting the below error which i believe is because i have multiple objects in the same hierarchy so its trying to create the upper objects int he hierarchy twice, what is the best way you guys have found to catch this or query if that item exists before creating my code it similar to below below

ERROR

ftrack_api.exception.ServerError: Server reported error: IntegrityError((_mysql_exceptions.IntegrityError) (1062, "Duplicate entry '780a712a-9bc3-11ea-b9ae-d61ccb4e321b-Assets' for key 'context_parent_id_key'") [SQL: u'INSERT INTO context (context_type, name, parent_id, id) VALUES (%s, %s, %s, %s)'] [parameters: (('task', 'Assets', u'780a712a-9bc3-11ea-b9ae-d61ccb4e321b', u'2fec278a-12d1-44fa-8e26-adc3b218a6bf'), ('task', 'Assets', u'780a712a-9bc3-11ea-b9ae-d61ccb4e321b', u'72fd181f-f72d-4f87-9cd8-74e579cfa588'), ('task', 'Assets', u'780a712a-9bc3-11ea-b9ae-d61ccb4e321b', u'9261c102-080b-45c6-9a07-d3e4eeca3fc1'))] (Background on this error at: http://sqlalche.me/e/gkpj))
[Finished in 21.9s]

 

CODE:

task = FTrack_session.create(object_type,{'name':object_name,'parent':FTrack_object_parent})

  • 4 weeks later...
Posted

Hi Peter,

 

The simplest solution is to use session.ensure() if there's a chance the object exists already. In any case, that line alone won't implicitly create any parents, so I read the error as a not very clear version of "can't create Task, as one with the same name already exists with that same parent".

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...