graph.push(zipcode)
            # add edge
            comm.CMTE_ZIP.add(zipcode)

            city = City.select(graph, data.CMTE_CITY).first()
            if not city:
                city = City()
                city.CITY = data.CMTE_CITY
                graph.push(city)
            # add edge
            comm.CMTE_CITY.add(city)

            party = Party.select(graph, data.CMTE_PTY_AFFILIATION).first()
            if not party:
                party = Party()
                party.PARTY = data.CMTE_PTY_AFFILIATION
                graph.push(party)
            # add edge
            comm.CMTE_PTY_AFFILIATION.add(party)

            state = State.select(graph, data.CMTE_ST).first()
            if not state:
                state = State()
                state.STATE = data.CMTE_ST
                graph.push(state)
                # add edge
            comm.CMTE_ST.add(state)

            # Commit it all
            graph.push(comm)
示例#2
0
                party = Party()
                party.PARTY = data.CAND_PTY_AFFILIATION
                graph.push(party)
            cand.CAND_PTY_AFFILIATION.add(party)

            year = ElectionYear.select(graph, data.CAND_ELECTION_YR ).first()
            if not year:
                year = ElectionYear()
                year.YEAR = data.CAND_ELECTION_YR
                graph.push(year)
            cand.CAND_ELECTION_YR.add(year)

            state = State.select(graph, data.CAND_OFFICE_ST ).first()
            if not state:
                state = State()
                state.STATE = data.CAND_OFFICE_ST
                graph.push(state)
            cand.CAND_OFFICE_ST.add(state)

            office = Office.select(graph, data.CAND_OFFICE).first()
            if not office:
                office = Office()
                office.OFFICE = data.CAND_OFFICE
                graph.push(office)
            cand.CAND_OFFICE.add(office)

            district = District.select(graph, data.CAND_OFFICE_DISTRICT).first()
            if not district:
                district = District()
                district.DISTRICT = data.CAND_OFFICE_DISTRICT
                graph.push(district)