Skip to content

Document sqlnbfmt as a custom SQL formatter plugin #388

@flyersworder

Description

@flyersworder

Hi! I maintain sqlnbfmt, a SQL formatter for notebook cells. We recently added a jupyterlab-code-formatter integration so users can format SQL in notebook cells interactively (toolbar, shortcuts, format-on-save).

It handles:

  • SQL in Python strings (query = "SELECT ...")
  • SQL in function calls (pd.read_sql("SELECT ..."), cursor.execute(...))
  • %%sql / %sql magic cells
  • F-string placeholders (f"SELECT * FROM {table}")

Setup

pip install sqlnbfmt jupyterlab-code-formatter
# ~/.jupyter/jupyter_notebook_config.py
from sqlnbfmt.jupyterlab_integration import register
register()  # or: register(dialect="postgres")

Then "Apply SQL Notebook Formatter" appears in the Format Cell menu.

Request

Would you be open to mentioning sqlnbfmt in the docs as an example of a custom formatter plugin? This could go in the README or a "Third-party formatters" section. Happy to submit a PR if that's preferred.

This would also help users discover that custom formatters are possible — I noticed #231 requesting entry point support, and documenting a working example might be useful context for that discussion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions