--- src/sql/run.py.orig
+++ src/sql/run.py
@@ -97,6 +97,17 @@
_cell_with_spaces_pattern = re.compile(r"(<td>)( {2,})")
+def _table_style(name):
+ """The prettytable style called name. prettytable >= 3.12 has the styles
+ in the TableStyle enum (its deprecated module constants reach the module
+ __dict__ only once accessed); older versions have only the constants.
+ Either way an unknown name raises KeyError, as before."""
+ name = name.upper()
+ if hasattr(prettytable, "TableStyle"):
+ return prettytable.TableStyle[name]
+ return prettytable.__dict__[name]
+
+
class ResultSet(list, ColumnGuesserMixin):
"""
Results of a SQL query.
@@ -113,7 +124,7 @@
else:
list.__init__(self, sqlaproxy.fetchall())
self.field_names = unduplicate_field_names(self.keys)
- self.pretty = PrettyTable(self.field_names, style=prettytable.__dict__[config.style.upper()])
+ self.pretty = PrettyTable(self.field_names, style=_table_style(config.style))
else:
list.__init__(self, [])
self.pretty = None