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
Hashes for pandas_gdc_agent-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4462cdc94a699e88f844b8e05fe6f12062fb4b683df937b7d7b7b3a1ad48cd5b |
|
MD5 | 20eb713133a1de8f7aaa09cd5906a041 |
|
BLAKE2b-256 | 6458e82e11fa8425b73471064c365331b2586a6fa08dd79633e8498c3edee2bc |