def list_field_to_reference():
 tablename_new = 'sector_id_reference'
 new_list_field = list_field_name = 'multi_sector_id'
 tablename_old_id_field = 'id'
 tablename_old = 'org_organisation'
 table_old = db[tablename_old]
 for a in range(2, 10):
  db[tablename_old].insert(name=('test_%s' % str(a)), organisation_type_id=(a % 5), uuid=('%s%s' % (table_old['uuid'].default, str(a))), multi_sector_id=[(a - 2), (a - 1), a])
 db.commit()
 s3migrate.list_field_to_reference(tablename_new, new_list_field, list_field_name, tablename_old_id_field, tablename_old)
 print tablename_old
 for row in db(table_old).select():
  print 'id: ', row[tablename_old_id_field], 'sector_id: ', row[list_field_name]
 print tablename_new
 for row in db(db[tablename_new]).select():
  print 'id: ', row[('%s_%s' % (tablename_old, tablename_old_id_field))], 'sector_id: ', row[new_list_field]

def list_field_to_reference ( ) : tablename_new = 'sector_id_reference' new_list_field = list_field_name = 'multi_sector_id' tablename_old_id_field = 'id' tablename_old = 'org_organisation' table_old = db [ tablename_old ] for a in range ( 2 , 10 ) : db [ tablename_old ] . insert ( name = ( 'test_%s' % str ( a ) ) , organisation_type_id = ( a % 5 ) , uuid = ( '%s%s' % ( table_old [ 'uuid' ] . default , str ( a ) ) ) , multi_sector_id = [ ( a - 2 ) , ( a - 1 ) , a ] ) db . commit ( ) s3migrate . list_field_to_reference ( tablename_new , new_list_field , list_field_name , tablename_old_id_field , tablename_old ) print tablename_old for row in db ( table_old ) . select ( ) : print 'id: ' , row [ tablename_old_id_field ] , 'sector_id: ' , row [ list_field_name ] print tablename_new for row in db ( db [ tablename_new ] ) . select ( ) : print 'id: ' , row [ ( '%s_%s' % ( tablename_old , tablename_old_id_field ) ) ] , 'sector_id: ' , row [ new_list_field ]
test for s3migrate() .