Skip to content

A SQLite-like tool for querying graphs from the command-line using graph query languages in in-memory Python.

License

Notifications You must be signed in to change notification settings

aplbrain/grandlite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grandlite

A SQLite-like tool for querying graphs from the command-line using graph query languages in in-memory Python.

Supports out-of-core graphs with Grand.

Installation

$ pip install grandlite

Usage

Get stats about a graph

$ poetry run grandlite --stats 'h-edgelist(pre:post)://white_1986_n2u.csv'
Nodes: 221
Edges: 1855
Density: 0.038153023447141096
Orphans: 0
Leaves: 7
Max degree: 44
Max node: RIMR
Self-loops: 52

Run an interactive Cypher session

$ grandlite my-graph.graphml
> match (a)-[]->(b) return a,b limit 3

        a       b
0  023620  364605
1  023620  438847
2  023620  462336

> save results.json

> exit()

Note that save [filename] will output csv, json, and jsonl files, depending on the extension provided; or will default to results-XXXX.json with XXX as a timestamp in ISO format, if no filename is provided.

For more information about saving, see the docs.

Command-line options

$ grandlite --help
usage: An interactive graph query tool for Cypher and other query languages.
       [-h]
       [-o {csv,json,jsonl}]
       [-q QUERY]
       [-l {cypher,dotmotif}]
       [--stats]
       [--convert OUTPUT_FILENAME]
       graph

positional arguments:
  graph                 The filename of the graph to load.

options:
  -h, --help            show this help message and exit
  -o {csv,json,jsonl}, --output {csv,json,jsonl}
                        The output format to use.
  -q QUERY, --query QUERY
                        If not provided, enters an interactive prompt.
  -l {cypher,dotmotif}, --language {cypher,dotmotif}
                        The query language to use (default: cypher).
  --stats               Print statistics about the graph and exit.
  --convert OUTPUT_FILENAME
                        Convert the graph to a new format, save to the
                        output filename specified, and exit.

Input formats

Grandlite supports a growing variety of input formats. For a complete list, see the docs.

Examples

OpenCypher

$ grandlite 'vertex:vertices.csv;edge:edges.csv'

CSV / Edgelist with or without headers

$ grandlite 'h-edgelist(pre:post)://white_1986_n2u.csv'

Made with 💙 at JHU APL