Skip to content

Conversation

@rolandwalker
Copy link
Contributor

Description

After dbcli/cli_helpers#97 we can set the alignment on a per-column basis using the colalign parameter.

In this PR we upgrade cli_helpers and set colalign for columns with a numeric type. This is more performant than using tabulate's numparse capability, and unlike numparse, works on nullable numeric columns.

The default alignment for numeric columns is changed from left to right, on the basis that this is the default for the vendor client. However, the user is free to change it back in ~/.myclirc .

Fixes #1102 .

Checklist

  • I've added this contribution to the changelog.md.
  • I've added my name to the AUTHORS file (or it's already there).
  • I ran uv run ruff check && uv run ruff format && uv run mypy --install-types . to lint and format the code.

After dbcli/cli_helpers#97 we can set the
alignment on a per-column basis using the colalign parameter.

In this PR we upgrade cli_helpers and set colalign for columns with
a numeric type.  This is more performant than using tabulate's
numparse capability, and unlike numparse, works on nullable numeric
columns.

The default alignment for numeric columns is changed from left to
right, on the basis that this is the default for the vendor client.
However, the user is free to change it back in ~/.myclirc .
@rolandwalker rolandwalker self-assigned this Jan 24, 2026
@scottnemes
Copy link
Contributor

Nice! It can actually suport center as well if you want to include that in the config file. Not sure on the use case, but it works anyway! Also will accept decimal but with the way decimals work I don't think it will actually ever do anything.

@rolandwalker
Copy link
Contributor Author

In the PyMySQL source it appears to be able to return Decimal types: https://github.com/PyMySQL/PyMySQL/blob/d7bb777e503d82bf2496113f07dd4ab249615efc/pymysql/converters.py#L353-L354 .

We can do center later if anyone wants it. It probably wouldn't make sense for just numeric data to be centered, and we'd need another configuration option.

@rolandwalker rolandwalker merged commit 675768a into main Jan 24, 2026
8 checks passed
@rolandwalker rolandwalker deleted the RW/configurable-numeric-alignment branch January 24, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Numeric Alignment Incorrect In Table Output

3 participants