EMBED YOUR TERMINAL RECORDINGS ONLINE

Mysql pagers

DATE: 2012-06-18
AUTHOR: Coder of Salvation
AUTHOR WWW: http://leon.vankammen.eu
RELATED ARTICLE: http://www.mysqlperformanceblog.com/2008/06/23/neat-trick...

Related recordings:

SUTRAPHP-INTRODUCTION
tags: sutraphp sutra php console cli eventbased
MORE OVERVIEW IN MYSQL WITH SELECTS
tags: mysql, select, more overview, console
THE UNIX TREE COMMAND
tags: unix console tree bash directory listing
GENERATING PHP & SQL (MAPPING) CODE
tags: sutra generate sql generate database php cms mysql
OUTLOOK IN SHELL: WYRD FOR REMIND
tags: outlook terminal calendar remind console
CD -
tags: bash
SSH TO ANOTHER SERVER
tags: ssh remote shell login server remote console
NOTITLE
tags: bash variable search replace
CONDITIONAL CRON USING DATE %A
tags: cron shellscript conditional bash schedule
CUT TEXT FROM CONSOLE OUTPUT
tags: cut manipulate text bash shellscript





EMBED THIS RECORDING:
<div><script id="playterm-MjAxMi0wNi9teXNxbHBhZ2VydHR5cmVjLTEzNDAwMTA5MTl8ODB4MjQ=" type="text/javascript" src="https://playterm.org/js/?hash=MjAxMi0wNi9teXNxbHBhZ2VydHR5cmVjLTEzNDAwMTA5MTl8ODB4MjQ=" class="size:80x24"></script></div>
I recorded this `mysql pagers` shellsession because pagers havent been explained too much in the
mysql docs. Nevertheless, its a great tool to monitor/automate/manage database output using
shellscript. 
Snippets

in mysql console
================
mysql> pager more
mysql> (do your select)
mysql> nopager

mycronscript.sh
===============
#!/bin/bash

dosomething(){
  cat - | grep Town
}

mysql -u root -pYOURPWD --pager=dosomething -e "SELECT * FROM customer" dbname

Coder of Salvation said

btw. as you can see in the cronscripts: storing passwords in shellscripts is ugly. Anyone got ideas
to improve this?

Matt Herr said

if somebody emails you "give me the last x of this or that", you can just do:
mysql> pager vim -
mysql> (do your select)
Then you can edit the contents, and write it to a file etc. =]

 

Name   
Email (never shown)  
Comment