Skip to main content

Python DB-API and SQLAlchemy interface for GraphQL APIs.

Project description

graphql-db-api PyPI version main workflow codecov

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

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)

Installation

I was having issues with apsw-3.9.2.post1 (the newest version of apsw that would install for me from PyPI) and ended up needing to follow the instructions here to build / install apsw from source. There is an open ticket on the APSW project to provide newer wheels. The issue might be triggered if the table name needs escaping and the error looked like:

SystemError: <method 'execute' of 'apsw.Cursor' objects> returned NULL without setting an exception

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlalchemy-graphqlapi-0.0.1.dev2.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqlalchemy_graphqlapi-0.0.1.dev2-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file sqlalchemy-graphqlapi-0.0.1.dev2.tar.gz.

File metadata

  • Download URL: sqlalchemy-graphqlapi-0.0.1.dev2.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.28.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for sqlalchemy-graphqlapi-0.0.1.dev2.tar.gz
Algorithm Hash digest
SHA256 7f3b6a763b09e66410068cafc0c47eeb56cc5d5d611131611f3e836ef12d53ce
MD5 24a7945d9dc6e2f18f1e836379de8517
BLAKE2b-256 d85eb42637b536d0862469a9cfb9904c83b696151dcb766eaf0639c4e99c81bd

See more details on using hashes here.

File details

Details for the file sqlalchemy_graphqlapi-0.0.1.dev2-py3-none-any.whl.

File metadata

  • Download URL: sqlalchemy_graphqlapi-0.0.1.dev2-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.28.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for sqlalchemy_graphqlapi-0.0.1.dev2-py3-none-any.whl
Algorithm Hash digest
SHA256 ee2dae6fe76098f0adc122615be858104c882bb3a72a42a6002ea43986fb4138
MD5 1800b263110067e089e3598df0a33095
BLAKE2b-256 496ca8bac3c24403d444562907f2f187a00e5b644d31283b3701a0015c72e91c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page