All Projects → betodealmeida → shillelagh

betodealmeida / shillelagh

Licence: MIT license
Making it easy to query APIs via SQL

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to shillelagh

databricks-dbapi
DBAPI and SQLAlchemy dialect for Databricks Workspace and SQL Analytics clusters
Stars: ✭ 21 (-87.79%)
Mutual labels:  sqlalchemy, dbapi
magql
The magical GraphQL framework that generates an API for your data.
Stars: ✭ 26 (-84.88%)
Mutual labels:  sqlalchemy
AUCR
Analyst Unknown Cyber Range - a micro web service framework
Stars: ✭ 24 (-86.05%)
Mutual labels:  sqlalchemy
mock-alchemy
SQLAlchemy mock helpers.
Stars: ✭ 44 (-74.42%)
Mutual labels:  sqlalchemy
graygram-web
www.graygram.com
Stars: ✭ 16 (-90.7%)
Mutual labels:  sqlalchemy
bag
A Python library for several purposes
Stars: ✭ 25 (-85.47%)
Mutual labels:  sqlalchemy
chm-documentation
chm documentation PostgreSQL pgadmin3 SQLAlchemy Django Flask jinja2 webpy doc chm compiled html help Postgres Postgre документация russian
Stars: ✭ 17 (-90.12%)
Mutual labels:  sqlalchemy
flask-template
Template for creating Flask based projects
Stars: ✭ 60 (-65.12%)
Mutual labels:  sqlalchemy
OpenAlchemy
Define SQLAlchemy models using the OpenAPI specification.
Stars: ✭ 39 (-77.33%)
Mutual labels:  sqlalchemy
CourseCake
By serving course 📚 data that is more "edible" 🍰 for developers, we hope CourseCake offers a smooth approach to build useful tools for students.
Stars: ✭ 21 (-87.79%)
Mutual labels:  sqlalchemy
soar-php
SQL optimizer and rewriter. - SQL 优化、重写器(辅助 SQL 调优)。
Stars: ✭ 140 (-18.6%)
Mutual labels:  sqlalchemy
AnyBlok
AnyBlok is a Python framework for building business applications.
Stars: ✭ 19 (-88.95%)
Mutual labels:  sqlalchemy
pyramid-cookiecutter-alchemy
[DEPRECATED - Please use https://github.com/pylons/pyramid-cookiecutter-starter instead] A Cookiecutter (project template) for creating a Pyramid project using SQLite for persistent storage, SQLAlchemy for an ORM, Alembic for database migrations, URL dispatch for routing, and Jinja2 for templating.
Stars: ✭ 39 (-77.33%)
Mutual labels:  sqlalchemy
trashed
Trashed is an organizational tool designed to help users keep their communities clean.
Stars: ✭ 13 (-92.44%)
Mutual labels:  sqlalchemy
hypothesis sqlalchemy
hypothesis strategies for generating SQLAlchemy objects
Stars: ✭ 24 (-86.05%)
Mutual labels:  sqlalchemy
py-data-api
A user-friendly client for AWS Aurora Serverless's Data API
Stars: ✭ 37 (-78.49%)
Mutual labels:  sqlalchemy
yosai alchemystore
SQLAlchemy-enabled Account Store for Yosai that features a flat Role-Based Access Control (RBAC) data model
Stars: ✭ 17 (-90.12%)
Mutual labels:  sqlalchemy
Flask-Validator
Validator for SQLAlchemy Models
Stars: ✭ 27 (-84.3%)
Mutual labels:  sqlalchemy
sqlalchemy-adapter
SQLAlchemy Adapter for PyCasbin
Stars: ✭ 53 (-69.19%)
Mutual labels:  sqlalchemy
django-rest-witchcraft
Django REST Framework integration with SQLAlchemy
Stars: ✭ 38 (-77.91%)
Mutual labels:  sqlalchemy

Shillelagh

https://coveralls.io/repos/github/betodealmeida/shillelagh/badge.svg?branch=master Documentation Status

PyPI - Python Version

Shillelagh (ʃɪˈleɪlɪ) is a Python library and CLI that allows you to query many resources (APIs, files, in memory objects) using SQL. It's both user and developer friendly, making it trivial to access resources and easy to add support for new ones.

The library is an implementation of the Python DB API 2.0 based on SQLite (using the APSW library):

from shillelagh.backends.apsw.db import connect

connection = connect(":memory:")
cursor = connection.cursor()

query = "SELECT * FROM a_table"
for row in cursor.execute(query):
    print(row)

There is also a SQLAlchemy dialect:

from sqlalchemy.engine import create_engine

engine = create_engine("shillelagh://")
connection = engine.connect()

query = "SELECT * FROM a_table"
for row in connection.execute(query):
    print(row)

And a command-line utility:

$ shillelagh
sql> SELECT * FROM a_table

Why SQL?

Sharks have been around for a long time. They're older than trees and the rings of Saturn, actually! The reason they haven't changed that much in hundreds of millions of years is because they're really good at what they do.

SQL has been around for some 50 years for the same reason: it's really good at what it does.

Why "Shillelagh"?

Picture a leprechaun hitting APIs with a big stick so that they accept SQL.

How is it different?

Shillelagh allows you to easily query non-SQL resources. For example, if you have a Google Spreadsheet you can query it directly as if it were a table in a database:

SELECT country, SUM(cnt)
FROM "https://docs.google.com/spreadsheets/d/1_rN3lm0R_bU3NemO0s9pbFkY5LQPcuy1pscv8ZXPtg8/edit#gid=0"
WHERE cnt > 0
GROUP BY country

You can even run INSERT/DELETE/UPDATE queries against the spreadsheet:

UPDATE "https://docs.google.com/spreadsheets/d/1_rN3lm0R_bU3NemO0s9pbFkY5LQPcuy1pscv8ZXPtg8/edit#gid=0"
SET cnt = cnt + 1
WHERE country != 'BR'

Queries like this are supported by adapters. Currently Shillelagh has the following adapters:

Name Type URI pattern Example URI
CSV File /path/to/file.csv /home/user/sample_data.csv
Datasette API http(s)://* https://global-power-plants.datasettes.com/global-power-plants/global-power-plants
GitHub API https://api.github.com/repos/${owner}/{$repo}/pulls https://api.github.com/repos/apache/superset/pulls
GSheets API https://docs.google.com/spreadsheets/d/${id}/edit#gid=${sheet_id} https://docs.google.com/spreadsheets/d/1LcWZMsdCl92g7nA-D6qGRqg1T5TiHyuKJUY1u9XAnsk/edit#gid=0
HTML table API http(s)://* https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_population
Pandas In memory Any variable name (local or global) my_df
S3 API s3://bucket/path/to/file s3://shillelagh/sample_data.csv
Socrata API https://${domain}/resource/${dataset-id}.json https://data.cdc.gov/resource/unsk-b7fc.json
System API system://${resource} system://cpu?interval=2
WeatherAPI API https://api.weatherapi.com/v1/history.json?key=${key}&q=${location} https://api.weatherapi.com/v1/history.json?key=XXX&q=London

There are also 3rd-party adapters:

A query can combine data from multiple adapters:

INSERT INTO "/tmp/file.csv"
SELECT time, chance_of_rain
FROM "https://api.weatherapi.com/v1/history.json?q=London"
WHERE time IN (
  SELECT datetime
  FROM "https://docs.google.com/spreadsheets/d/1_rN3lm0R_bU3NemO0s9pbFkY5LQPcuy1pscv8ZXPtg8/edit#gid=1648320094"
)

The query above reads timestamps from a Google sheet, uses them to filter weather data from WeatherAPI, and writes the chance of rain into a (pre-existing) CSV file.

New adapters are relatively easy to implement. There's a step-by-step tutorial that explains how to create a new adapter to an API or filetype.

Installation

Install Shillelagh with pip:

$ pip install 'shillelagh'

You also need to install optional dependencies, depending on the adapter you want to use:

$ pip install 'shillelagh[console]'       # to use the CLI
$ pip install 'shillelagh[datasetteapi]'  # for Datasette
$ pip install 'shillelagh[githubapi]'     # for GitHub
$ pip install 'shillelagh[gsheetsapi]'    # for GSheets
$ pip install 'shillelagh[htmltableapi]'  # for HTML tables
$ pip install 'shillelagh[pandasmemory]'  # for Pandas in memory
$ pip install 'shillelagh[s3selectapi]'   # for S3 files
$ pip install 'shillelagh[socrataapi]'    # for Socrata API
$ pip install 'shillelagh[systemapi]'     # for CPU information
$ pip install 'shillelagh[weatherapi]'    # for WeatherAPI

Alternatively, you can install everything with:

$ pip install 'shillelagh[all]'
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].