Python DB-API and SQLAlchemy interface for GraphQL APIs.
Project description
graphql-db-api
A Python DB API 2.0 for GraphQL APIs
This module allows you to query GraphQL APIs using SQL.
SQLAlchemy support
This module provides a SQLAlchemy dialect.
from sqlalchemy.engine import create_engine
engine = create_engine('graphql://host:port/path?is_https=0')
Example Usage
Querying Connections
from sqlalchemy import create_engine
from sqlalchemy import text
# We use GraphQL SWAPI (The Star Wars API) c/o Netlify:
engine = create_engine('graphql://swapi-graphql.netlify.app/.netlify/functions/index')
with engine.connect() as connection:
# Demonstration of requesting nested resource of homeworld
# and then selecting fields from it
for row in connection.execute(text("select name, homeworld__name from 'allPeople?include=homeworld'")):
print(row)
Querying Lists
from sqlalchemy import create_engine
from sqlalchemy import text
engine = create_engine('graphql://pet-library.moonhighway.com/')
with engine.connect() as connection:
for row in connection.execute(text("select id, name from 'allPets?is_connection=0'")):
print(row)
Superset support
In order to use with Superset, install this package and then use the graphql
protocol in the SQLAlchemy URI like: graphql://swapi-graphql.netlify.app/.netlify/functions/index
. We install a db_engine_spec
so Superset should recognize the driver.
Roadmap
- Non-Connections top level
- Path traversal (basic)
- Path traversal (basic + nested)
- Path traversal (list / connection)
- Bearer Tokens in
Authorization
Header - Advanced Auth (e.g. with token refresh)
- Passing Headers (e.g. Auth in other locations)
- Filtering
- Sorting
- Relay Pagination
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
Close
Hashes for hakurei_sqlalchemy-graphqlapi-0.0.1.dev19.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f26ccfcbc94eb6edd78af8b5cf801a084fae74b5529b827f679e765c6df8f925 |
|
MD5 | d8bc81d7e688185109949a222d6bbd25 |
|
BLAKE2b-256 | c04b3f1537e0595b15fce24ba2e1ca9cbe9dfe9af6905ccceb4198120e7fb5cc |
Close
Hashes for hakurei_sqlalchemy_graphqlapi-0.0.1.dev19-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68ef97a04b5e953bb25069be54d64b1cf372c4742225d335c7b1c06463ee11fb |
|
MD5 | 6646d97ed541b5c9e6f92fcb01786aa0 |
|
BLAKE2b-256 | bc06ff997861b0d1fb28dcef0b3bd93d10b919a539582699fd704416a741503c |