https://github.com/aplbrain/grandlite
A SQLite-like tool for querying graphs from the command-line using graph query languages in in-memory Python.
https://github.com/aplbrain/grandlite
aplbrain command-line cypher dotmotif grand-graph graph graph-database graph-query graphs in-memory neo4j opencypher sqlite
Last synced: 7 months ago
JSON representation
A SQLite-like tool for querying graphs from the command-line using graph query languages in in-memory Python.
- Host: GitHub
- URL: https://github.com/aplbrain/grandlite
- Owner: aplbrain
- License: apache-2.0
- Created: 2023-05-15T18:58:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-18T22:43:15.000Z (almost 2 years ago)
- Last Synced: 2024-05-16T01:13:37.403Z (over 1 year ago)
- Topics: aplbrain, command-line, cypher, dotmotif, grand-graph, graph, graph-database, graph-query, graphs, in-memory, neo4j, opencypher, sqlite
- Language: Python
- Homepage:
- Size: 75.2 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://github.com/aplbrain/grand).
## Installation
```bash
$ pip install grandlite
```## Usage
### Get stats about a graph
```bash
$ 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
```bash
$ grandlite my-graph.graphml
``````cypher
> match (a)-[]->(b) return a,b limit 3a 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](./docs/Saving.md).
## 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]
graphpositional 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](./docs/Input-Formats.md).
### Examples
#### OpenCypher
```bash
$ grandlite 'vertex:vertices.csv;edge:edges.csv'
```#### CSV / Edgelist with or without headers
```bash
$ grandlite 'h-edgelist(pre:post)://white_1986_n2u.csv'
```---
---