Skip to content

Commit

Permalink
Merge branch 'betodealmeida:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank-pathania authored Jul 3, 2024
2 parents efddd62 + 70a60df commit 0b2f95e
Show file tree
Hide file tree
Showing 86 changed files with 3,688 additions and 206 deletions.
26 changes: 11 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,6 @@ repos:
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
language_version: python3
exclude: ^templates/

## If like to embrace black styles even in the docs:
# - repo: https://github.com/asottile/blacken-docs
# rev: v1.9.1
# hooks:
# - id: blacken-docs
# additional_dependencies: [black]

- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
Expand All @@ -57,7 +43,7 @@ repos:
# additional_dependencies: [flake8-bugbear]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.910' # Use the sha / tag you want to point at
rev: 'v1.9.0' # Use the sha / tag you want to point at
hooks:
- id: mypy
exclude: ^templates/
Expand All @@ -77,12 +63,14 @@ repos:
# hooks:
# - id: reorder-python-imports
# args: [--application-directories=.:src]

- repo: https://github.com/hadialqattan/pycln
rev: v2.1.2
hooks:
- id: pycln
args: [--config=pyproject.toml]
exclude: ^templates/

- repo: local
hooks:
- id: pylint
Expand All @@ -92,9 +80,17 @@ repos:
types: [python]
exclude: ^templates/
args: [--disable=use-implicit-booleaness-not-comparison]

- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
hooks:
- id: pyupgrade
args:
- --py38-plus

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.7
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Contributors
* Alex Rothberg <[email protected]>
* Elias Sebbar <[email protected]>
* Arash Afghahi <[email protected]>
* Johannes Körner <[email protected]>
38 changes: 38 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,44 @@ Changelog
Next
====

- Add ``import_dbapi()`` to supress warning (#452)

Version 1.2.19 - 2024-04-03
===========================

- Relax ``tabulate`` dependency for Apache Superset (#443)

Version 1.2.18 - 2024-03-27
===========================

- Fix OAuth2 flow in GSheets (#438)

Version 1.2.17 - 2024-02-23
===========================

- Add support for GitHub issues (#433)

Version 1.2.16 - 2024-02-22
===========================

- Allow for custom expiration time in the generic JSON/XML adapters (#429)
- Use a different JSONPath library that handles root better (#431)

Version 1.2.15 - 2024-02-13
===========================

- Preset adapter now handles pagination, offset and limit (#427)

Version 1.2.14 - 2024-01-05
===========================

- Preset adapter can now query workspaces (#423)

Version 1.2.13 - 2024-01-04
===========================

- Add custom adapter for the Preset API (#421)

Version 1.2.12 - 2023-12-05
===========================

Expand Down
30 changes: 29 additions & 1 deletion docs/adapters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ You can select data from any `Datasette <https://datasette.io/>`_ table, by usin
GitHub
======

The GitHub adapter currently allows pull requests to be queried (other endpoints can be easily added):
The GitHub adapter currently allows pull requests and issues to be queried (other endpoints can be easily added):

.. code-block:: sql
Expand Down Expand Up @@ -475,3 +475,31 @@ The generic XML adapter is based on the generic JSON; the only difference is tha
</root>
Would get mapped to two columns, ``foo`` and ``baz``, with values ``bar`` and ``{"qux": "quux"}`` respectively.

Preset (https://preset.io)
==========================

There are two adapters based on the generic JSON adapter that are specific to `Preset <https://preset.io>`_. They handle authentication and pagination of the APIs, so they're more efficient than the generic one.

To configure, you need an access token and secret:

.. code-block:: python
from shillelagh.backends.apsw.db import connect
connection = connect(
":memory:",
# create tokens/secrets at https://manage.app.preset.io/app/user
adapter_kwargs={
"presetapi": {
"access_token": "",
"access_secret": "",
},
"presetworkspaceapi": {
"access_token": "",
"access_secret": "",
},
},
)
The token and secret should normally be the same, but because the workspace API is slightly different from the main Preset API they were implemented as different adapters.
1 change: 1 addition & 0 deletions examples/csvfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A simple example showing the CSV adapter.
"""

from shillelagh.backends.apsw.db import connect

if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions examples/dataframe.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A simple example showing the Pandas adapter.
"""

import pandas as pd

from shillelagh.backends.apsw.db import connect
Expand Down
1 change: 1 addition & 0 deletions examples/datasette.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A simple example showing the Datasette adapter.
"""

from shillelagh.backends.apsw.db import connect

if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions examples/generic_xml.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A simple example showing the generic XML.
"""

import sys

from shillelagh.backends.apsw.db import connect
Expand Down
1 change: 1 addition & 0 deletions examples/github.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A simple example showing the GitHub adapter.
"""

from shillelagh.backends.apsw.db import connect

if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions examples/gsheets.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A simple example showing the GSheets adapter.
"""

from shillelagh.backends.apsw.db import connect

if __name__ == "__main__":
Expand Down
38 changes: 38 additions & 0 deletions examples/preset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
A simple example querying the Preset API.
"""

from shillelagh.backends.apsw.db import connect

if __name__ == "__main__":
connection = connect(
":memory:",
# create tokens/secrets at https://manage.app.preset.io/app/user
adapter_kwargs={
"presetapi": {
"access_token": "",
"access_secret": "",
},
"presetworkspaceapi": {
"access_token": "",
"access_secret": "",
},
},
)
cursor = connection.cursor()

SQL = """
SELECT * FROM
"https://api.app.preset.io/v1/teams/"
LIMIT 1
"""
for row in cursor.execute(SQL):
print(row)

SQL = """
SELECT * FROM
"https://d90230ca.us1a.app-sdx.preset.io/api/v1/chart/"
LIMIT 12
"""
for row in cursor.execute(SQL):
print(row)
1 change: 1 addition & 0 deletions examples/socrata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A simple example showing the Socrata adapter.
"""

from shillelagh.backends.apsw.db import connect

if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions examples/weatherapi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A simple example showing the WeatherAPI adapter.
"""

import os
import sys
from datetime import datetime, timedelta
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ version_scheme = "no-guess-dev"

[tool.flake8]
max-line-length = 90

[tool.ruff]
exclude = [
"templates",
]
10 changes: 1 addition & 9 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@ certifi==2022.6.15
# via requests
charset-normalizer==2.1.0
# via requests
exceptiongroup==1.1.3
# via cattrs
greenlet==2.0.2
# via
# shillelagh
# sqlalchemy
idna==3.3
# via requests
importlib-metadata==6.7.0
# via shillelagh
packaging==23.0
# via shillelagh
platformdirs==3.11.0
Expand All @@ -48,14 +44,10 @@ six==1.16.0
sqlalchemy==1.4.39
# via shillelagh
typing-extensions==4.3.0
# via
# cattrs
# shillelagh
# via shillelagh
url-normalize==1.4.3
# via requests-cache
urllib3==1.26.10
# via
# requests
# requests-cache
zipp==3.15.0
# via importlib-metadata
Loading

0 comments on commit 0b2f95e

Please sign in to comment.