Skip to main content

jusi-sql

jusi-sql is the independently installable SQL plugin family for Jusi 1.0. It owns the user-facing %%sql contract and the provider-neutral code that SQLite, PostgreSQL, ClickHouse, and future database plugins should share. It is not an exact provider and therefore publishes no jusi.plugins.v1 entry point.

Family contract

Every exact SQL provider advertises the same catalog claim:

  • family sql, magic sql
  • capabilities execute, bootstrap, followup, complete, interrupt, and editor_actions
  • shared sql syntax and indentation profiles
  • terminal-interactive presentation

An exact provider may refine syntax after handoff (for example pgsql or clickhouse), but may not change the shared capabilities or presentation. Providers own connections, transactions, dialect metadata queries, cancellation, result rendering, selection meaning, and application IPC.

The family owns target configuration and selection, deterministic ownership of one %%sql magic, the initial handoff payload, continuing-operation parsing, metadata-aware completion, safe cache paths, and private application staging. There is no process-global live-session registry. A worker and its exact provider session belong to one client in one notebook-runtime generation.

Configuration

The canonical 1.0 shape is:

[sql.targets.warehouse]
provider = "clickhouse"
host = "db.internal"
database = "analytics"

[sql.targets.reporting]
provider = "postgres"
host = "pg.internal"
dbname = "reports"

Then a cell starts with %%sql warehouse. The provider is resolved only inside the target kernel against adapters installed in that runtime. Missing, unknown, unavailable, and ambiguous providers fail without printing target options. The historical [sql.warehouse] shape is accepted during migration, but it cannot be mixed with [sql.targets.*].

Secrets may be provider options because the target worker needs them. They are never placed in catalog metadata or error messages. Prefer provider-owned environment or secret resolution where possible.

Exact-provider integration

Catalog code stays lightweight:

from jusi_sql import sql_catalog_entry

def catalog_entry():
    return sql_catalog_entry(
        plugin_id="postgres",
        plugin_version="1.0.0",
        distribution="jusi-postgres",
        kernel_extension="jusi_postgres.kernel",
        worker_entry_point="jusi_postgres.worker:create_worker",
        provider_presentation={"syntax": "pgsql", "indent": "sql"},
    )

The exact kernel module retains its own attested identity while sharing the dispatcher:

from jusi_sql.kernel import SqlKernelAdapter

_adapter = SqlKernelAdapter(
    plugin_id="postgres",
    plugin_version="1.0.0",
    selectors=("postgres", "postgresql"),
)

jusi_kernel_adapter_v1 = _adapter.manifest
configure_jusi_runtime_v1 = _adapter.configure
load_ipython_extension = _adapter.load

Each installed adapter registers its identity in the shared dispatcher. After all catalog modules attest, %%sql resolves the alias and emits one exact 1.0 handoff. Registration rejects selector collisions and an unrelated extension already owning %%sql; it never relies on import order.

Worker code uses composition rather than the retired handler hierarchy:

from jusi_sql.worker import SqlWorker

def create_worker(context):
    return SqlWorker(context, PostgresSession)

PostgresSession implements execute, followup, complete, interrupt, editor_action, and close. interrupt is called concurrently and must be prompt and thread-safe. Recoverable database errors should raise jusi.plugin_api.OperationRejected; broken sessions should fail normally so Jusi fences the worker.

Completion and metadata

complete_sql consumes a MetadataSnapshot and Jusi's full completion payload. It returns absolute Unicode code-point ranges, preserves suffix text, handles empty prefixes, and understands schema, table, alias, and column qualification. Exact providers only collect dialect metadata and supply keyword lists.

MetadataCache provides stale-while-refresh snapshots. sql_cache_directory creates stable provider-scoped paths while recursively redacting secret values from the fingerprint.

Providers using VisiData may install the optional visidata extra and use SqlSheetActions, bind_sql_actions, and install_visidata_commands. This supplies the common numeric/gf fetch and gc/gr transaction commands on result sheets and all derived sheets. Live callbacks remain attached to their own provider sheet; the family does not keep a global current session.

Migration from 0.x providers

Remove DisplayHandlerSpec, BaseSqlHandler, SqlSheetRuntime, environment payloads, and the jusi plugin-runtime bootstrap. Split each provider into catalog, kernel adapter, worker, and terminal-application import boundaries. Keep VisiData and driver imports out of catalog and worker startup.

PostgreSQL- and ClickHouse-specific connection, streaming, binary-value, Kerberos, transaction, and cancellation code remains in those packages. Their duplicated target parsing, magic registration, completion models, relation parsing, metadata cache, safe cache path, and operation dispatch should be deleted in favor of this family package during their 1.0 migrations.

Initialize before the first query

With a bootstrap-capable Jusi core, execute a header-only %%sql analytics cell, or use :JusiBootstrap to preserve an existing draft. The shared magic hook resolves the exact provider and emits bootstrap: true with sql: "" in its private handoff. SqlExecuteRequest.bootstrap carries that distinction into the provider; it must remain in any staged application payload.

Providers initialize their application and metadata loading, then display jusi_sql.visidata.sql_bootstrap_sheet(alias) instead of constructing a query result. No dummy SQL statement or draft is executed. The ordinary worker execute operation still owns client creation; completion and followups reuse that client. Metadata can arrive asynchronously. PostgreSQL's collect_metadata = false continues to disable schema metadata collection.

The optional empty_sql adapter argument remains for legacy direct magic execution; explicit bootstrap bypasses it. Upgrade core, this family, and all installed SQL providers together: every provider claiming this family must support the same bootstrap semantics.

Metadata

Release files for jusi-sql 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jusi-sql 0.2.1
File Size Uploaded Provenance Actions
jusi_sql-0.2.1.tar.gz 18.6 kB Without provenance Details for jusi_sql-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jusi-sql 0.2.1
File Interpreter ABI Platform Actions
jusi_sql-0.2.1-py3-none-any.whl Python 3 none any Details for jusi_sql-0.2.1-py3-none-any.whl

Total release size: 37.5 kB

Release files / jusi_sql-0.2.1.tar.gz

Download URL jusi_sql-0.2.1.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1c548d72fdbfff2b86c192c8769ef1713ed3816c8698245d96973da04508ad26
BLAKE2b-256 checksum
How to use checksums
fde977a79ea3b9f971f155a10c1ef862c4cd8026fc437c1c42a34f2594be61b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.1

Release files / jusi_sql-0.2.1-py3-none-any.whl

Download URL jusi_sql-0.2.1-py3-none-any.whl
Size 19.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
14a26747385e7b016494f599fd1a6dc5ac71f718c832ba7759b46d63c3e28f5f
BLAKE2b-256 checksum
How to use checksums
5860a359bc2c17f43a8caad1fc772e310c33f4c7bcfb194f6c688285754ffc5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.1

Security for jusi-sql 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page