An open API service indexing awesome lists of open source software.

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.

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 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](./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]
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](./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'
```

---

Made with 💙 at JHU APL

---