README.md 1.23 KB
Newer Older
davebshow's avatar
davebshow committed
1
# [aiogremlin 3.2.4](https://pypi.python.org/pypi/aiogremlin/3.2.4)
davebshow's avatar
davebshow committed
2

davebshow's avatar
davebshow committed
3
[Official Documentation](http://aiogremlin.readthedocs.org/en/latest/)
davebshow's avatar
davebshow committed
4

davebshow's avatar
davebshow committed
5
6
`aiogremlin` is a port of the official `Gremlin-Python` designed for integration with
event loop based asynchronous Python networking libraries, including `asyncio`,
davebshow's avatar
davebshow committed
7
`aiohttp`, and `tornado`. It uses the `async/await` syntax introduced
davebshow's avatar
davebshow committed
8
in PEP 492, and is therefore Python 3.5+ only.
davebshow's avatar
davebshow committed
9

davebshow's avatar
davebshow committed
10
11
12
`aiogremlin` tries to follow `Gremlin-Python` as closely as possible both in terms
of API and implementation. It is regularly rebased against the official Apache Git
repository, and will be released according to the TinkerPop release schedule.
davebshow's avatar
davebshow committed
13

davebshow's avatar
davebshow committed
14
15
Note that this *NOT* an official Apache project component, it is a
*THIRD PARTY PACKAGE!*
16

davebshow's avatar
davebshow committed
17
## Getting Started
davebshow's avatar
davebshow committed
18
19

```python
davebshow's avatar
davebshow committed
20
21
import asyncio
from aiogremlin import DriverRemoteConnection, Graph
davebshow's avatar
davebshow committed
22

23

davebshow's avatar
davebshow committed
24
loop = asyncio.get_event_loop()
25
26


davebshow's avatar
davebshow committed
27
28
29
30
31
async def go(loop):
  remote_connection = await DriverRemoteConnection.open(
    'ws://localhost:8182/gremlin', 'g')
  g = Graph().traversal().withRemote(remote_connection)
  vertices = await g.V().toList()
davebshow's avatar
davebshow committed
32
  await remote_connection.close()
davebshow's avatar
davebshow committed
33
  return vertices
davebshow's avatar
davebshow committed
34

35

davebshow's avatar
davebshow committed
36
37
38
vertices = loop.run_until_complete(go(loop))
print(vertices)
# [v[1], v[2], v[3], v[4], v[5], v[6]]
39
```