rows=[run_sql("select tag,data,flag from aidPERSONID use index (`ptf-b`) where tag like %s and personid=%s and flag=%s",('rt_%',str(person_id),str(ticket_id)))]
except(ProgrammingError,OperationalError):
rows=[run_sql("select tag,data,flag from aidPERSONID where tag like %s and personid=%s and flag=%s",('rt_%',str(person_id),str(ticket_id)))]
use_index=False
iflen(rows)<1:
return[]
else:
rows=[]
ids=[]
ifuse_index:
ifnotmatching:
ids=run_sql("select distinct flag from aidPERSONID use index (`ptf-b`) where personid=%s and tag like %s",(str(person_id),'rt_%'))
else:
ids=run_sql("select distinct flag from aidPERSONID use index (`tdf-b`) where tag=%s and data=%s and personid=%s",('rt_'+str(matching[0]),str(matching[1]),str(person_id)))
else:
ifnotmatching:
ids=run_sql("select distinct flag from aidPERSONID where personid=%s and tag like %s",(str(person_id),'rt_%'))
else:
ids=run_sql("select distinct flag from aidPERSONID where tag=%s and data=%s and personid=%s",('rt_'+str(matching[0]),str(matching[1]),str(person_id)))
fortidinids:
ifuse_index:
rows.append(run_sql("select tag,data,flag from aidPERSONID use index (`ptf-b`) where tag like %s and personid=%s and flag = %s",('rt_%',str(person_id),str(tid[0]))))
else:
rows.append(run_sql("select tag,data,flag from aidPERSONID where tag like %s and personid=%s and flag = %s",('rt_%',str(person_id),str(tid[0]))))
print"update_authornames_tables: More then one result or missing authornames?? Something is wrong, not updating"+str(authornames_row)+str(authornames_bibrefs_row)
return
iflen(authornames_row)==1:
# we have an hit for the name string; check if there is the 'new' bibref associated,
# if yes there is nothing to do, otherwise shold add it here and in the ANbibrefs table
ifauthornames_row[0][2].count(bibref)<1:
ifbconfig.TABLES_UTILS_DEBUG:
print'update_authornames_tables: Adding new bibref to '+str(authornames_row)+' '+str(name)+' '+str(bibref)
run_sql("update aidAUTHORNAMES set bibrefs=%s where id=%s",