bash script with sql to get the number of records from multiple tables.

Here is the bash script:

echo $1
for i in $( sqlplus amit/passwd@tns @get_count.sql |sed  -n \’/COUNT/,/Disconnected/p\’|sed \’/COUNT/ d\’|sed \’/—/ d\’|sed \’/Disconnected/ d\’|tr \’n\’ \’ \’  )
let count=30-${#temp}
for ((I=1; I <= $count ; I++))
printf \” \”
echo  \”${names[$j]}    : $i\”
# echo $j
let j=j+1

and the required sql script:

select count(*) from errorlog;
select count(*) from amit1log;
select count(*) from amit2log;
select count(*) from amit3log;
select count(*) from amit4log;

I have verified this to be working on Solaris and Oracle. Might need some changes for mysql, but should not be much.


Execute mysql command from shell

phpMyAdmin is a very slow application if you want to execute a query on your database. If you know the name of the database then any GUI tool is an overhead. So I have written a one liner shell script to do that for me 🙂

Here\’s the script:

echo \”select * from table where field like \”%$1%\”\”|mysql -h -u amit -p -D amit -r –password=hello

When run with one argument it will execute the sql query directly without asking for password also.

phpMyEdit – Mysql table viewer, editor and php code generator.

As a developer, whenever you want to write the php code to get the data from the MySQL database, sometimes it becomes tiresome and time taking. And what if you had to do it dynamically. Well I have not generated the code dynamically using phpMyEdit, but I believe that should be pretty much doable.

But what you would definately like this open source php code to view, edit and generate php code, saving you some time to concentrate on better and interesting things. The official website has this description:

phpMyEdit generates PHP code for displaying/editing MySQL tables in HTML. All you need to do is to write a simple calling program (a utility to do this is included). It includes a huge set of table manipulation functions (record addition, change, view, copy, and removal), table sorting, filtering, table lookups, and more.

I liked it for the very little php coding that I do anyways for maintaining my websites.