Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 0.11.1dev

* [Fix] No longer showing the Slack link in error messages

## 0.11.0 (2025-03-03)

* [API Change] Disabled `%sql` and `%%sql` on Databricks ([#1047](https://github.com/ploomber/jupysql/issues/1047))
Expand Down
2 changes: 0 additions & 2 deletions src/sql/connection/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from IPython.core.error import UsageError
import sqlglot
import sqlparse
from ploomber_core.exceptions import modify_exceptions


from sql.store import store
Expand Down Expand Up @@ -951,7 +950,6 @@ def close(self):
self._connection.engine.dispose()

@classmethod
@modify_exceptions
def _start_sqlalchemy_connection(cls, engine, connect_str):
try:
connection = engine.connect()
Expand Down
3 changes: 0 additions & 3 deletions src/sql/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ def exception_factory(name):
def _error(message):
exc = error.UsageError(message)
exc.error_type = name
# this attribute will allow the @modify_exceptions decorator to add the
# community link
exc.modify_exception = True
return exc

return _error
Expand Down
3 changes: 0 additions & 3 deletions src/sql/inspect.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from sqlalchemy import inspect
from prettytable import PrettyTable
from ploomber_core.exceptions import modify_exceptions
from sql.connection import ConnectionManager
from sql import exceptions
import math
Expand Down Expand Up @@ -165,7 +164,6 @@ def _assign_column_specific_stats(col_stats, is_numeric):
return col_stats


@modify_exceptions
class Columns(DatabaseInspection):
"""
Represents the columns in a database table
Expand Down Expand Up @@ -195,7 +193,6 @@ def __init__(self, name, schema, conn=None) -> None:
self._table_txt = self._table.get_string()


@modify_exceptions
class TableDescription(DatabaseInspection):
"""
Generates descriptive statistics.
Expand Down
3 changes: 0 additions & 3 deletions src/sql/magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from ipywidgets import interact
except ModuleNotFoundError:
interact = None
from ploomber_core.exceptions import modify_exceptions
from IPython.core.magic import (
Magics,
cell_magic,
Expand Down Expand Up @@ -367,7 +366,6 @@ def execute(self, line="", cell="", local_ns=None):
line=line, cell=cell, local_ns=local_ns, is_interactive_mode=False
)

@modify_exceptions
def _execute(self, line, cell, local_ns, is_interactive_mode=False):
"""
This function implements the cell logic; we create this private
Expand Down Expand Up @@ -626,7 +624,6 @@ def interactive_execute_wrapper(**kwargs):

legal_sql_identifier = re.compile(r"^[A-Za-z0-9#_$]+")

@modify_exceptions
def _persist_dataframe(
self, raw, conn, user_ns, append=False, index=True, replace=False
):
Expand Down
2 changes: 0 additions & 2 deletions src/sql/magic_plot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from IPython.core.magic import Magics, line_magic, magics_class, no_var_expand
from IPython.core.magic_arguments import argument, magic_arguments
from ploomber_core.exceptions import modify_exceptions

try:
from traitlets.config.configurable import Configurable
Expand Down Expand Up @@ -76,7 +75,6 @@ class SqlPlotMagic(Magics, Configurable):
type=float,
help="Histogram binwidth",
)
@modify_exceptions
def execute(self, line="", cell="", local_ns=None):
"""
Plot magic
Expand Down
7 changes: 0 additions & 7 deletions src/sql/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

from ploomber_core.dependencies import requires
from ploomber_core.exceptions import modify_exceptions
from jinja2 import Template

from sql import exceptions, display
Expand Down Expand Up @@ -106,7 +105,6 @@ def _between(conn, table, column, whislo, whishi, with_=None):


# https://github.com/matplotlib/matplotlib/blob/b5ac96a8980fdb9e59c9fb649e0714d776e26701/lib/matplotlib/cbook/__init__.py
@modify_exceptions
def _boxplot_stats(conn, table, column, whis=1.5, autorange=False, with_=None):
"""Compute statistics required to create a boxplot"""
if not conn:
Expand Down Expand Up @@ -549,7 +547,6 @@ def histogram(
return ax


@modify_exceptions
def _histogram(
table, column, bins, with_=None, conn=None, facet=None, breaks=None, binwidth=None
):
Expand Down Expand Up @@ -688,7 +685,6 @@ def _histogram(
return bin_, height, bin_size


@modify_exceptions
def _histogram_stacked(
table,
column,
Expand Down Expand Up @@ -765,7 +761,6 @@ def _histogram_stacked(
return data


@modify_exceptions
def _filter_aggregate(*filter_queries):
"""Return a single filter query based on multiple queries.

Expand Down Expand Up @@ -797,7 +792,6 @@ def _filter_aggregate(*filter_queries):
return final_filter


@modify_exceptions
def _bar(table, column, with_=None, conn=None):
"""get x and height for bar plot"""
if not conn:
Expand Down Expand Up @@ -985,7 +979,6 @@ def bar(
return ax


@modify_exceptions
def _pie(table, column, with_=None, conn=None):
"""get x and height for pie chart"""
if not conn:
Expand Down
2 changes: 0 additions & 2 deletions src/sql/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from typing import Iterator, Iterable
from collections.abc import MutableMapping
from jinja2 import Template
from ploomber_core.exceptions import modify_exceptions
import sql.connection
import difflib

Expand Down Expand Up @@ -80,7 +79,6 @@ def infer_dependencies(self, query, key):
dependencies.append(table)
return dependencies

@modify_exceptions
def store(self, key, query, with_=None):
if "-" in key:
raise exceptions.UsageError(
Expand Down
6 changes: 0 additions & 6 deletions src/tests/test_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@

from conftest import runsql
from sql.connection import PLOOMBER_DOCS_LINK_STR
from ploomber_core.exceptions import COMMUNITY
import psutil

COMMUNITY = COMMUNITY.strip()

DISPLAYLIMIT_LINK = (
'<a href="https://jupysql.ploomber.io/en/'
Expand Down Expand Up @@ -1163,7 +1161,6 @@ def test_autolimit(ip):
Set the environment variable $DATABASE_URL

For more details, see: {PLOOMBER_DOCS_LINK_STR}
{COMMUNITY}
"""


Expand All @@ -1181,7 +1178,6 @@ def test_error_on_invalid_connection_string(ip_empty, clean_conns):
Ref: https://docs.sqlalchemy.org/en/20/core/engines.html#database-urls

For more details, see: {PLOOMBER_DOCS_LINK_STR}
{COMMUNITY}
""" # noqa


Expand All @@ -1207,7 +1203,6 @@ def test_error_on_invalid_connection_string_with_existing_conns(ip_empty, clean_
Perhaps you meant to use driver the dialect: "sqlite"

For more details, see: {PLOOMBER_DOCS_LINK_STR}
{COMMUNITY}
""" # noqa


Expand Down Expand Up @@ -1235,7 +1230,6 @@ def test_error_on_invalid_connection_string_with_possible_typo(ip_empty, clean_c
Example: %sql postgresql://username:password@hostname/dbname

For more details, see: {PLOOMBER_DOCS_LINK_STR}
{COMMUNITY}
""" # noqa


Expand Down
8 changes: 4 additions & 4 deletions src/tests/test_magic_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ def ip_snippets(ip):
ip.run_cell("%sql sqlite://")
ip.run_cell(
"""
%%sql --save high_price --no-execute
%%sql --save high_price --no-execute
SELECT *
FROM "test_store"
WHERE price >= 1.50
"""
)
ip.run_cell(
"""
%%sql --save high_price_a --no-execute
%%sql --save high_price_a --no-execute
SELECT *
FROM "high_price"
WHERE symbol == 'a'
"""
)
ip.run_cell(
"""
%%sql --save high_price_b --no-execute
%%sql --save high_price_b --no-execute
SELECT *
FROM "high_price"
WHERE symbol == 'b'
Expand Down Expand Up @@ -986,7 +986,7 @@ def test_force_delete_all_with_variable_substitution(ip_snippets):
def test_force_delete_all_child_query(ip_snippets, arg):
ip_snippets.run_cell(
"""
%%sql --save high_price_b_child --no-execute
%%sql --save high_price_b_child --no-execute
SELECT *
FROM "high_price_b"
WHERE symbol == 'b'
Expand Down
2 changes: 0 additions & 2 deletions src/tests/test_magic_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,6 @@ def test_sqlplot_snippet_deletion(ip_snippets, arg):
TABLE_NAME_TYPO_MSG = """
There is no table with name 'subst' in the default schema
Did you mean: 'subset'
If you need help solving this issue, send us a message: https://ploomber.io/community
"""


Expand All @@ -793,7 +792,6 @@ def test_sqlplot_snippet_typo(ip_snippets):

MISSING_TABLE_ERROR_MSG = """
There is no table with name 'missing' in the default schema
If you need help solving this issue, send us a message: https://ploomber.io/community
"""


Expand Down
7 changes: 0 additions & 7 deletions src/tests/test_syntax_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
from IPython.core.error import UsageError

from sql.error_handler import ORIGINAL_ERROR, CTE_MSG
from ploomber_core.exceptions import COMMUNITY


COMMUNITY = COMMUNITY.strip()


@pytest.fixture
Expand Down Expand Up @@ -39,7 +35,6 @@ def query_multiple():
def _common_strings_check(err):
assert ORIGINAL_ERROR.strip() in str(err.value)
assert CTE_MSG.strip() in str(err.value)
assert COMMUNITY in str(err.value)
assert isinstance(err.value, UsageError)


Expand All @@ -51,7 +46,6 @@ def test_syntax_error_incorrect_column_name(ip, query_incorrect_column_name):

message_incorrect_column_name_long = f"""\
(sqlite3.OperationalError) near "FROM": syntax error
{COMMUNITY}
[SQL: SELECT first_(name FROM author;]
""" # noqa

Expand All @@ -75,7 +69,6 @@ def test_syntax_error_multiple_statements(ip, query_multiple):

message_multiple_statements_long = f"""\
(sqlite3.OperationalError) near ";": syntax error
{COMMUNITY}
[SQL: ALTER TABLE author RENAME another_name;]
""" # noqa

Expand Down
Loading