user=dst_pgpass[3], password=dst_pgpass[4]) src_cur = src.cursor() dst_cur = dst.cursor() src_cur.execute( "select id, name, app_label, model from django_content_type where id in (10,11,22,23,24,30,31,37,47,48,49,53,54,55,56,57,58,59,60)" ) for src_row in src_cur: assignments = [] #id assignments.append( django_content_type_mapping.get_django_content_type_id(src_row[0])) #name assignments.append(src_row[1]) #app_label assignments.append(src_row[2]) #model assignments.append(src_row[3]) try: dst_cur.execute( "insert into django_content_type(id, name, app_label, model) values (%s, %s, %s, %s)", assignments) dst.commit() except Exception as error: print print type(error)
dst = psycopg2.connect(host=dst_pgpass[0], database="geonode", user=dst_pgpass[3], password=dst_pgpass[4]) src_cur = src.cursor() dst_cur = dst.cursor() src_cur.execute("select id, name, content_type_id, codename from auth_permission where id in (28,29,30,31,32,33,64,65,66,67,68,69,70,71,72,88,89,90,91,92,93,109,110,111,124,125,138,139,143,144,145,146,147,148,149,150,151,155,156,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190)") for src_row in src_cur: assignments = [] #id assignments.append(src_row[0]+10000) #name assignments.append(src_row[1]) #content_type_id assignments.append(django_content_type_mapping.get_django_content_type_id(src_row[2])) #codename assignments.append(src_row[3]) try: dst_cur.execute("insert into auth_permission(id, name, content_type_id, codename) values (%s, %s, %s, %s)", assignments) dst.commit() except Exception as error: print print type(error) print str(error) + "select id, name, content_type_id, codename from auth_permission" print str(src_row) dst.rollback() dst.commit()