Пример #1
0
                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
                city = City()
                city.CITY = data.CAND_CITY
                graph.push(city)
            cand.CAND_CITY.add(city)

            status = Status.select(graph, data.CAND_STATUS).first()
            if not status:
                status = Status()
                status.STATUS = data.CAND_STATUS
                graph.push(status)
            cand.CAND_STATUS.add(status)

            party = Party.select(graph, data.CAND_PTY_AFFILIATION).first()
            if not party:
                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)