Open doublep opened 2 years ago
Hi!
I can't replicate this. I wonder what it depends upon. Do you see the same issue if you terminate the show create table
statement with \G
instead of ;
?
I thought it was the standard behavior, but then this explains why I haven't found this reported.
\G
as query terminator linefeeds are displayed as linefeeds, not as \n
.~/.myclirc
.You might go ahead and upgrade mycli if possible, as I am running 1.26.1. But I don't think that is the issue.
I just tried Python 3.10 and it doesn't cause an issue.
The version of MySQL might matter.
Another thing to double-check is running your command after nopager
, but I don't think that will be the issue.
Does it only happen with show create table
or is it common to every output?
You might go ahead and upgrade mycli if possible, as I am running 1.26.1. But I don't think that is the issue.
Done, no change. (Debian has a bug in that sqlglot
package is not installed or even present; had to install it with pip3
.)
The version of MySQL might matter.
MariaDB 10.6.8-1 (both server and client) from Debian packages.
Another thing to double-check is running your command after nopager
I don't know what that is.
Does it only happen with show create table or is it common to every output?
select 'a\nb';
+------+
| a
b |
+------+
| a\nb |
+------+
That's neat. The column header is wrong too. It should be
select 'a\nb';
+---+
| a |
| b |
|---|
| a |
| b |
+---+
Maybe that's a clue.
As I'm a programmer myself, I could do some debugging. But keep in mind that I'm completely unfamiliar with the project and my knowledge of Python is pretty rusty as well. So, you'd need to give me some instructions on what to do and what to look for.
Try setting
table_format = psql
in ~/.myclirc
if you currently have ascii
.
Yes, that sort-of fixes the appearance. However, given that it says "# Recommended: ascii", I still see this as a bug.
Also, in psql
mode the value is easy to read, but not easy to use:
> create table xxx (x int); show create table xxx;
Query OK, 0 rows affected
Time: 0.023s
+-------+----------------------------+
| Table | Create Table |
|-------+----------------------------|
| xxx | CREATE TABLE "xxx" ( |
| | "x" int(11) DEFAULT NULL |
| | ) |
+-------+----------------------------+
You cannot just copy-paste this into something else, you have to invoke an editor to trim down needless crap. In comparison, the standard client gives a statement that is ready to be copied and executed:
> show create table xxx;
+-------+---------------------------------------------------+
| Table | Create Table |
+-------+---------------------------------------------------+
| xxx | CREATE TABLE "xxx" (
"x" int(11) DEFAULT NULL
) |
+-------+---------------------------------------------------+
It would be best, from my point of view, if Mycli could somehow special-case certain queries to skip drawing nice tables, but instead prefer usability. Maybe optionally.
You make good points.
The behavior of ascii
makes no sense with \n
and we should look into the relevant code for bugs.
It's desirable to have ways to emulate the stock client for familiarity, and then have optional ways to make interaction better.
I use psql
mode for reading and then \G
selectively for copy-paste.
Version 1.25.0.
When I issue a command like
show create table ...
, I get hardly-readable output in one string, with\n
in place of linefeeds. In comparison, in the standard command-line client, this is shown with linefeeds preserved, making the output easy to read.I don't see any options in
~/.myclirc
that would control this.