In [4]: %sql \dt
Running query in 'postgresql://'
Out[4]:
+--------+------+-------+---------+
| Schema | Name | Type | Owner |
+--------+------+-------+---------+
| public | test | table | jupyter |
+--------+------+-------+---------+
In [5]: %sql \d test
Running query in 'postgresql://'
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[5], line 1
----> 1 get_ipython().run_line_magic('sql', '\\d test')
File ~/VENV/lib/python3.14/site-packages/sql/magic.py:365, in SqlMagic.execute(self, line, cell, local_ns)
257 @no_var_expand
258 @needs_local_scope
259 @line_magic("sql")
(...) 337 )
338 def execute(self, line="", cell="", local_ns=None):
339 """
340 Runs SQL statement against a database, specified by
341 SQLAlchemy connect string.
(...) 363
364 """
--> 365 return self._execute(
366 line=line, cell=cell, local_ns=local_ns, is_interactive_mode=False
367 )
File ~/VENV/lib/python3.14/site-packages/sql/magic.py:623, in SqlMagic._execute(self, line, cell, local_ns, is_interactive_mode)
620 handle_exception(e, command.sql, self.short_errors)
621 except Exception as e:
622 # Handle non SQLAlchemy errors
--> 623 handle_exception(e, command.sql, self.short_errors)
File ~/VENV/lib/python3.14/site-packages/sql/error_handler.py:115, in handle_exception(error, query, short_error)
113 _display_error_msg_with_trace(error, detailed_message)
114 else:
--> 115 raise error
File ~/VENV/lib/python3.14/site-packages/sql/magic.py:577, in SqlMagic._execute(self, line, cell, local_ns, is_interactive_mode)
574 parameters = user_ns
576 try:
--> 577 result = run_statements(conn, command.sql, self, parameters=parameters)
579 if (
580 result is not None
581 and not isinstance(result, str)
(...) 584 # Instead of returning values, set variables directly in the
585 # users namespace. Variable names given by column names
587 if self.autopandas or self.autopolars:
File ~/VENV/lib/python3.14/site-packages/sql/run/run.py:65, in run_statements(conn, sql, config, parameters)
58 if (
59 config.feedback >= 1
60 and hasattr(result, "rowcount")
61 and result.rowcount > 0
62 ):
63 display.message_success(f"{result.rowcount} rows affected.")
---> 65 result_set = ResultSet(result, config, statement, conn)
66 return select_df_type(result_set, config)
File ~/VENV/lib/python3.14/site-packages/sql/run/resultset.py:52, in ResultSet.__init__(self, sqlaproxy, config, statement, conn)
46 self._done_fetching()
47 else:
48 # in all other cases, 2 allows us to know if there are more rows
49 # for example when creating a table, the results contains one row, in
50 # such case, fetching 2 rows will tell us that there are no more rows
51 # and can set the _mark_fetching_as_done flag to True
---> 52 self.fetchmany(size=2)
54 self._finished_init = True
56 if conn:
File ~/VENV/lib/python3.14/site-packages/sql/run/resultset.py:433, in ResultSet.fetchmany(self, size)
431 self._results = []
432 self._pretty_table.clear()
--> 433 self._extend_results(returned)
435 if len(returned) < size:
436 self.mark_fetching_as_done()
File ~/VENV/lib/python3.14/site-packages/sql/run/resultset.py:102, in ResultSet._extend_results(self, elements)
99 to_add = self._config.displaylimit - len(self._results)
100 self._results.extend(elements)
101 self._pretty_table.add_rows(
--> 102 elements if self._config.displaylimit == 0 else elements[:to_add]
103 )
TypeError: 'generator' object is not subscriptable
What happens?
"\dt" command is OK, but "\d table" produces the exception
I installed pgspecial <2 as stated in the documentation
jupysql 0.11.1
pgspecial 1.13.1
psycopg 3.3.3
psycopg2 2.9.11
SQLAlchemy 2.0.49
To Reproduce
An example:
OS:
Linux
JupySQL Version:
0.11.1
Full Name:
Marc
Affiliation:
N/A