Skip to content

Conversation

@safi50
Copy link

@safi50 safi50 commented Jul 4, 2023

Function Results:

  • Stored agload_test_graph data with 72,500 edges and 72,500 vertices from AGE to CSV in 1.2 seconds.
  • Loadedagloa_test_graph data 72,500 edges and 72,500 vertices from CSV to AGE graph in 2.5 seconds

Graphs with Nested Properties:

  • Stored a nested graph with complex properties containing 100,000 vertices and 50,000 edges from AGE to CSV in 2.7 seconds
  • Loaded the same nested graph with 100k vertices and 50k edges from CSV to AGE in 3.0 seconds.

Store Age to CSV Function - Description:

  • This function exports the specified graph from AGE to CSV files.
  • If a vertex or node has nested properties, it is loaded to a JSON file instead.
  • The Function fetched data directly from the AGE tables bypassing Cypher queries.

Parameters:

    - conn: A psycopg2 connection object to Postgres.
        Example:
            conn = psycopg2.connect(host="", 
                                database="", 
                                user="", 
                                password="")

    - graph_name: The name of the graph to be exported.
    - path: The directory path where the exported CSV/JSON files will be saved.
  • The function throws an exception if any errors occur during the export process.

Store CSV to AGE Function - Description

  • This function loads CSV / JSON data into an Apache AGE graph database.
  • Data should be appropriately formatted for the function to work.
  • If a vertex or an edge contains nested properties, it will be stored in JSON file instead of CSV.

FOR CSV FILES:

  • In Vertex Files: atleast 1 column named as 'id' is required.
  • In Edge Files: Following Columns are required:
    1. 'start_id', 2. 'end_id', 3. 'start_vertex_type', 4. 'end_vertex_type'

FOR JSON FILES:

  • For Vertex Files: The JSON file should contain a key named 'id' for each vertex.
  • For Edge Files: The JSON file should contain keys named as following:
    1. 'start_id', 2. 'end_id', 3. 'start_vertex_type', 4. 'end_vertex_type' for each edge.

NOTE: In CSV and JSON files, additional columns and keys respectively will count as properties.

  • The function also supports bulk data loading to improve performance.
  • The function throws an exception if any errors occur during the loading process.

Parameters:

conn: ext.connection - The database connection object.
graph_name: str - The name of the Apache AGE graph.
path: str - The path to the CSV or JSON file or directory containing such files.
with_labels: bool - An optional argument which specifies whether
                     new labels should be created in the database. 
- Default value  for with_labels is True.
  • If with_labels is False , function assumes that vlabels and elabels already exist.

NOTE: Set with_labels to False if you are loading data to an existing graph.

Raises:
Exception: An exception is raised if the given path is neither a file nor a directory
or if the file format is invalid.

@muhammadshoaib muhammadshoaib changed the base branch from python-networkx-driver to networkx August 1, 2023 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant