Hasura GDC agent based on pandas.
Project description
pandas_gdc_agent
This project explores the Hasura Graphql Data Connectors (GDC) using pandas Dataframe as backend.
To quickly get started, please go through a sample app in example.py.
GDCAgent
Link to pip package: https://pypi.org/project/pandas-gdc-agent/
The GDCAgent constructor takes a list of tuples, where the first element
is the table name and the second element is the DataFrame which corresponds
to the table name. To setup a GDCAgent, run the following:
# setting up GDC Agent
agent = GDCAgent([("table1",df1),("table2", df2)])
Please note that the dataframe must have the primary key as index.
After setting up the GDCAgent, start the GDCAgent server by running the
following:
# starting the GDC Agent
agent.run_agent()
When you run the GDCAgent, it starts a flask server and exposes the required
endpoints explained here.
Run example
The example.py uses the chinook database. To run the example, first create a
virtual environment:
python3 -m venv gdc_env
Now, activate the virtual environment and install the requirements
source gdc_env/bin/activate
pip install -r requirements.txt
Next, start the GDC agent:
python example.py
Now start a Hasura Graphql Engine:
curl https://raw.githubusercontent.com/hasura/graphql-engine/stable/install-manifests/docker-compose/docker-compose.yaml -o docker-compose.yml
docker-compose up
Now apply the following metadata:
POST /v1/metadata
{
"type": "replace_metadata",
"args": {
"metadata": {
"version": 3,
"backend_configs": {
"dataconnector": {
"reference": {
"uri": "http://localhost:5000/"
}
}
},
"sources": [
{
"name": "chinook",
"kind": "reference",
"tables": [
{
"table": "Album",
"object_relationships": [
{
"name": "Artist",
"using": {
"manual_configuration": {
"remote_table": "Artist",
"column_mapping": {
"ArtistId": "ArtistId"
}
}
}
}
]
},
{
"table": "Artist",
"array_relationships": [
{
"name": "Album",
"using": {
"manual_configuration": {
"remote_table": "Album",
"column_mapping": {
"ArtistId": "ArtistId"
}
}
}
}
]
}
],
"configuration": {
"tables": [ "Artist", "Album" ]
}
}
]
}
}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pandas_gdc_agent-0.0.3.tar.gz.
File metadata
- Download URL: pandas_gdc_agent-0.0.3.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a06f2514ed3b93f2a940701a5a9e3cb0bea8b016c570e05f3b21d109619c2617
|
|
| MD5 |
20a7a4dd32316478df4f661615160852
|
|
| BLAKE2b-256 |
c6443412b4f5d1f4d533412093a1fdb2cf0ce4206493f7c227b1465c558dd90f
|
File details
Details for the file pandas_gdc_agent-0.0.3-py3-none-any.whl.
File metadata
- Download URL: pandas_gdc_agent-0.0.3-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4462cdc94a699e88f844b8e05fe6f12062fb4b683df937b7d7b7b3a1ad48cd5b
|
|
| MD5 |
20eb713133a1de8f7aaa09cd5906a041
|
|
| BLAKE2b-256 |
6458e82e11fa8425b73471064c365331b2586a6fa08dd79633e8498c3edee2bc
|