semvec/pypi-packages huggingface dataset:
psycopg3-agensgraph 0.1.3
psycopg v3 adapter for agensgraph
License: Apache-2.0
Requires Python: >=3.9
Keywords: postgresql,agensgraph,client,adapter,psycopg

# AgensGraph Python Driver

AgensGraph Python Driver allows Python programs to connect to an AgensGraph database. It extends [Psycopg3](http://psycopg.org/) with adapters for AgensGraph and thereby supports additional data types such as `Vertex`, `Edge`, and `Path` to represent graph data.

### NOTE: 
This is a fork of the original [agensgraph-python](https://github.com/bitnine-oss/agensgraph-python) library and has been ported to psycopg3 - The original seemed unmaintained for some time. 

## Install

```sh
$ pip install -U pip
$ pip install psycopg

$ pip install /path/to/agensgraph/python/
```

## Example

```python
import psycopg
import psycopg3_agensgraph

conn = psycopg.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
$ pip install pytest
$ pytest tests
```

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