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.dev16.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b90dacaf27c8e596afaf56ec82bd253713f0b1ee4271d864da4cced547a08127 |
|
MD5 | 0d1c3dbc8297eca73da2c91d69b7979e |
|
BLAKE2b-256 | 1ed4ae8d8b3f5b08d3587759a8b783c688a3ad9d5e7c5733213be1b56f088db3 |
Close
Hashes for hakurei_sqlalchemy_graphqlapi-0.0.1.dev16-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d3e598b34c1ef7fe7ab1694899dae5865b9fac6b5f9e76382f430ae110258ee |
|
MD5 | ed0afe77c63081f49676324562a43bb3 |
|
BLAKE2b-256 | 89d0e5968c13a87b48ccc7040e0829130e6c75ffe1d78c107eb0b734d4dfb7b0 |