Ejemplo n.º 1
0
def get_politicos():

    with driver.session() as session:
        results = session.run(MATCH_POLITICOS)
        if results:
            return results.data()
        else:
            return None
Ejemplo n.º 2
0
def get_politico(uuid):

    with driver.session() as session:
        politico_record = session.run(MATCH_POLITICO, uuid=uuid).single()
        if politico_record:
            return politico_record.data()
        else:
            return None
Ejemplo n.º 3
0
def create_politico(politico):

    with driver.session() as session:
        politico_record = session.run(CREATE_POLITICO, politico=politico).single()
        if politico_record:
            # Little workaround to get the UUID since its creation is lazy and needs another operation after create.
            return session.run(MATCH_POLITICO_WITHOUT_UUID, politico=politico).single()
        else:
            return None
Ejemplo n.º 4
0
def update_politico(uuid, partido):

    with driver.session() as session:
        # Delete previous relation
        session.run(DELETE_POLITICO_PARTIDO_RELATION, uuid=uuid)
        # Create new relation and updates property partido_filtro from related node.
        politico_record = session.run(UPDATE_POLITICO_PARTIDO, uuid=uuid, partido=partido).single()
        if politico_record:
            return politico_record.data()
        else:
            return None
Ejemplo n.º 5
0
def import_csv(csv_file):

    # Comment dbms.directories.import=import for being able to get the csv from any folder.
    # A better aproach would be using neo4j tools for import but was mandatory to create a import endpoint.
    with driver.session() as session:

        # CARGO node creation
        session.run(CREATE_CARGO_NODE_QUERY, csvfile=csv_file)

        # CCAA node creation
        session.run(CREATE_CCAA_NODE_QUERY, csvfile=csv_file)

        # GENERO node creation
        session.run(CREATE_GENERO_NODE_QUERY, csvfile=csv_file)

        # GENERO node creation
        session.run(CREATE_PARTIDO_NODE_QUERY, csvfile=csv_file)

        # POLITICO node creation
        session.run(CREATE_POLITICO_NODE_QUERY, csvfile=csv_file)
Ejemplo n.º 6
0
def delete_politico(uuid):

    with driver.session() as session:
        session.run(DELETE_POLITICO, uuid=uuid)