Monday, 15 March 2010

Print escape characters in clear text in the MySQL CLI -



Print escape characters in clear text in the MySQL CLI -

i have mysql table may contain escaped characters in rows, illustration csv_line_terminator field have values e.g. '\n', '\r\n' etc.

this makes hard debug because mysql cli interprets actual values:

mysql> select id,csv_line_terminator feed_feed; +----+---------------------+ | id | csv_line_terminator | +----+---------------------+ | 1 | null | | 2 | null | | 3 | null | | 4 | | +----+---------------------+ 4 rows in set (0.01 sec)

i want print:

mysql> select id,csv_line_terminator feed_feed; +----+---------------------+ | id | csv_line_terminator | +----+---------------------+ | 1 | null | | 2 | null | | 3 | null | | 4 | \r\n | +----+---------------------+ 4 rows in set (0.01 sec)

is there setting or in mysql cli behaviour instead?

i think can custom output pager command explained here. difficulty find out base of operations command translate endline chars visual representation. tricky way create php or python script (or other language) , pass pager

in php script set

$argv = $_server['argv']; $argc = $_server['argc']; if($argc > 1){ str_replace("/n",'/n',$argv[1]); str_replace("/r",'/r',$argv[1]); str_replace("/t",'/t',$argv[1]); } , in .sh file set

#!/bin/sh php yourfile.php

and set pager pager yourshfil.sh

mysql

No comments:

Post a Comment