https://github.com/skaiworldwide-oss/agensgraph-python
A Python driver for AgensGraph Multi-Model Database
https://github.com/skaiworldwide-oss/agensgraph-python
genai graphdb multi-model-database nosql postgresql
Last synced: 11 months ago
JSON representation
A Python driver for AgensGraph Multi-Model Database
- Host: GitHub
- URL: https://github.com/skaiworldwide-oss/agensgraph-python
- Owner: skaiworldwide-oss
- License: apache-2.0
- Created: 2016-10-07T22:06:15.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-03-24T04:56:37.000Z (11 months ago)
- Last Synced: 2025-04-13T12:57:37.514Z (11 months ago)
- Topics: genai, graphdb, multi-model-database, nosql, postgresql
- Language: Python
- Homepage: http://www.bitnine.net
- Size: 45.9 KB
- Stars: 20
- Watchers: 8
- Forks: 9
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AgensGraph Python Driver
AgensGraph Python Driver allows Python programs to connect to an AgensGraph database. Since it is [Psycopg2](http://initd.org/psycopg/) type extension module for AgensGraph, it supports additional data types such as `Vertex`, `Edge`, and `Path` to represent graph data.
## Features
- Cypher query support for Psycopg2 PostgreSQL Python driver (enables cypher queries directly)
- Deserialize AgensGraph results (AGType) to Vertex, Edge, Path
## Build From Source
```sh
git clone https://github.com/skaiworldwide-oss/agensgraph-python
cd agensgraph-python
python setup.py install
```
## Example
```python
import psycopg2
import agensgraph
conn = psycopg2.connect("dbname=test host=127.0.0.1 user=agens")
cur = conn.cursor()
cur.execute("DROP GRAPH IF EXISTS t CASCADE")
cur.execute("CREATE GRAPH t")
cur.execute("SET graph_path = t")
cur.execute("CREATE (:v {name: 'AgensGraph'})")
conn.commit();
cur.execute("MATCH (n) RETURN n")
v = cur.fetchone()[0]
print(v.props['name'])
```
## Test
You may run the following command to test AgensGraph Python Driver.
```sh
python setup.py test
```
Before running the command, set the following environment variables to specify which database you will use for the test.
Variable Name | Meaning
---------------------------- | ---------------------------
`AGENSGRAPH_TESTDB` | database name to connect to
`AGENSGRAPH_TESTDB_HOST` | database server host
`AGENSGRAPH_TESTDB_PORT` | database server port
`AGENSGRAPH_TESTDB_USER` | database user name
`AGENSGRAPH_TESTDB_PASSWORD` | user password