Coder Social home page Coder Social logo

simonw / datasette-jq Goto Github PK

View Code? Open in Web Editor NEW
17.0 4.0 0.0 11 KB

Datasette plugin that adds a custom SQL function for executing jq expressions against JSON values

License: Apache License 2.0

Python 100.00%
datasette datasette-plugin jq datasette-io

datasette-jq's Introduction

datasette-jq

PyPI CircleCI License

Datasette plugin that adds custom SQL functions for executing jq expressions against JSON values.

Install this plugin in the same environment as Datasette to enable the jq() SQL function.

Usage:

select jq(
    column_with_json,
    "{top_3: .classifiers[:3], v: .version}"
)

See the jq manual for full details of supported expression syntax.

Interactive demo

You can try this plugin out at datasette-jq-demo.datasette.io

Sample query:

select package, "https://pypi.org/project/" || package || "/" as url,
jq(info, "{summary: .info.summary, author: .info.author, versions: .releases|keys|reverse}")
from packages

Try this query out in the interactive demo.

datasette-jq's People

Contributors

simonw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

datasette-jq's Issues

Error installing this plugin

  File "/usr/local/lib/python3.8/site-packages/datasette_jq/__init__.py", line 2, in <module>
    import pyjq
  File "/usr/local/lib/python3.8/site-packages/pyjq.py", line 4, in <module>
    from six.moves import urllib
ModuleNotFoundError: No module named 'six'

Appears to be this issue - doloopwhile/pyjq#43 - a missing six dependency in pyjq.

Installing this plugin causes an error when running Datasette

I tried installing datasette-jq on the command-line version of Datasette (version 0.58.1).

The installation was successful:

Successfully installed datasette-jq-0.2.1 pyjq-2.5.2

But afterwards starting Datasette gives this error when running on the command line:

Traceback (most recent call last):
  File "/usr/local/bin/datasette", line 33, in <module>
    sys.exit(load_entry_point('datasette==0.58.1', 'console_scripts', 'datasette')())
  File "/usr/local/bin/datasette", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/usr/local/Cellar/datasette/0.58.1/libexec/lib/python3.9/site-packages/datasette/cli.py", line 15, in <module>
    from .app import Datasette, DEFAULT_SETTINGS, SETTINGS, SQLITE_LIMIT_ATTACHED, pm
  File "/usr/local/Cellar/datasette/0.58.1/libexec/lib/python3.9/site-packages/datasette/app.py", line 30, in <module>
    from .views.database import DatabaseDownload, DatabaseView
  File "/usr/local/Cellar/datasette/0.58.1/libexec/lib/python3.9/site-packages/datasette/views/database.py", line 21, in <module>
    from datasette.plugins import pm
  File "/usr/local/Cellar/datasette/0.58.1/libexec/lib/python3.9/site-packages/datasette/plugins.py", line 24, in <module>
    pm.load_setuptools_entrypoints("datasette")
  File "/usr/local/Cellar/datasette/0.58.1/libexec/lib/python3.9/site-packages/pluggy/manager.py", line 299, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/local/Cellar/datasette/0.58.1/libexec/lib/python3.9/site-packages/datasette_jq/__init__.py", line 2, in <module>
    import pyjq
  File "/usr/local/Cellar/datasette/0.58.1/libexec/lib/python3.9/site-packages/pyjq.py", line 5, in <module>
    import _pyjq
ImportError: dlopen(/usr/local/Cellar/datasette/0.58.1/libexec/lib/python3.9/site-packages/_pyjq.cpython-39-darwin.so, 2): Library not loaded: /usr/local/opt/jq/lib/libjq.1.dylib
  Referenced from: /usr/local/Cellar/datasette/0.58.1/libexec/lib/python3.9/site-packages/_pyjq.cpython-39-darwin.so
  Reason: image not found

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.