Skip to main content

VisiData for database queries

Project description

vdsql: VisiData for Databases

A VisiData interface for databases

Powered by Ibis.

Features

  • query data in VisiData from any supported backend
  • output resulting query in SQL, Substrait, or Python

Requirements

  • Python 3.8
  • VisiData 2.10.2
  • Ibis 3.2

Confirmed supported backends

  • SQLite
  • MySQL
  • PostgreSQL
  • DuckDB
  • ClickHouse
  • Google BigQuery
  • Snowflake

Other backends supported by Ibis

These backends are supported by Ibis and should work, but haven't specifically been tested with vdsql. If you have have problems connecting, please file an issue.

  • Apache Impala
  • Datafusion
  • Dask
  • PySpark
  • HeavyAI

Install latest release

This will install both:

  • the usual vd with the vdsql plugin available (use -f vdsql to use Ibis instead of builtin loaders),

  • the vdsql script that acts identically to vd but will use Ibis instead of VisiData's builtin loader.

    pip install vdsql

Or install manually as a VisiData plugin (cutting edge development)

pip install git+https://github.com/visidata/vdsql.git

Install Ibis backends

To minimize dependencies, only the sqlite backend is included by default. Install other backends for Ibis directly, and they will be supported automatically:

pip install 'ibis-framework[postgres]'

Usage

Open a database

vdsql foo.sqlite  # or .sqlite3
vdsql mysql://...
vdsql postgres://...
vdsql foo.duckdb  # or .ddb
vdsql clickhouse://explorer@play.clickhouse.com:9440/?secure=1
vdsql bigquery:///bigquery-public-data

vdsql <file_or_url>

vd -f ibis <file_or_url>

where file_or_url is any connection string supported by ibis.connect() or any of the filetypes and options that VisiData itself supports.

Commands

A decent amount of work has gone into making vdsql work just like VisiData.

You can learn about VisiData starting with the Intro to VisiData Tutorial and the VisiData documentation.

There are a few differences, however:

  • Use " (dup-sheet) to run a new base query, including added columns, filtering for the current selection, and applying the current sort order.
  • By default vdsql will only get 10000 rows from a database source. To get a different number, use z" to create a new sheet with a different limit.
  • Some VisiData commands aren't implemented using the database engine.

The base VisiData commands can only use the 10000 loaded rows, and this might be misleading, so most not-implemented commands should be disabled.

But if you want to use the commands anyway, knowing the dataset is incomplete, you can use g' to freeze the current set of loaded rows into a new sheet.

This sheet is a plain (non-database) VisiData sheet, so all VisiData commands can be used on it.

Freezing the column type

Use ' to cast the current column to its given type, which persists into future queries (with ").

Sidebar

vdsql uses the VisiData sidebar (introduced in v2.9) to show the SQL query for the current view.

  • To toggle the sidebar on/off, press b.
  • To choose a sidebar option, press zb.
  • To open the sidebar as its own sheet, press gb.

In this way you can compose a SQL expression using VisiData commands, open the SQL sidebar, and save the resulting query to a file (or copy it into your system clipboard buffer).

License

vdsql is licensed under the Apache 2.0 license.

Share and enjoy!

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

vdsql-0.2.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

vdsql-0.2-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file vdsql-0.2.tar.gz.

File metadata

  • Download URL: vdsql-0.2.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for vdsql-0.2.tar.gz
Algorithm Hash digest
SHA256 0cb6f99b03ae672ecb06f4c1da20c79f8915b8c7519f8932efe599c10e71b688
MD5 82112afa74158ae5fd508d7fdf2adfe8
BLAKE2b-256 83a9e6b271bb41a921ed58417b5232cdeec6a336d1708b2910a538cf38de251f

See more details on using hashes here.

File details

Details for the file vdsql-0.2-py3-none-any.whl.

File metadata

  • Download URL: vdsql-0.2-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for vdsql-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 20a74e9fc834f93250fb4ea2303796a756b07eb05dbf76c14e86f4208048e8f4
MD5 a14a3c4b9d64c7c711a5af67322cf649
BLAKE2b-256 873820a62f4c211af1ddc1671609f5fa55555a50c9df30f6eff097e2134e1412

See more details on using hashes here.

Supported by

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