peter divers Posted May 22, 2020 Report Share Posted May 22, 2020 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}) Link to comment Share on other sites More sharing options...
Guest Posted June 18, 2020 Report Share Posted June 18, 2020 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". Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now