LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-13-2016, 11:13 AM   #16
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918

Quote:
Originally Posted by Amit15 View Post
What you have done will show some column with checkbox. What I want is when I perform
Code:
select * from tablename
The results that I get in terminal should be displayed in Zenity list like the attachment Capture.png
Which is from the following Link
When I did that
Code:
echo "SELECT bookId,Author,Title,Pulication,Edition,Copies,Date_pur,price,Status FROM bookdetails" | mysql LibraryManagement -N -u root -pmysql123 >> tempAgenda.dat | zenity --list --title="List Records" --text="" --column="bookId" --column="Author" --column="Title" --column="Pulication"--column="Edition" --column="Copies" --column="Date of purchase" --column="price" --column="Status" --height=310 --width=790;
I get the result in attachment Screenshot from picture.png
Also i have attached the tempAgent.dat SreenShot
i use process substitution in my example and you are using pipes (which mite work if you didnt redirect the output to a file and away from the pipe -- maybe try tee)
?
Quote:
Originally Posted by Amit15 View Post
And Guys please help me with
what happens when you change that line to:
Code:
echo INSERT INTO bookdetails (Author, Title, Pulication, Edition, Copies, Date_pur, price,Status) VALUES ('Author','Title','Publication','Edition',1,'10/13/2016',3.00,'Status');
?

Last edited by schneidz; 10-13-2016 at 11:18 AM.
 
Old 10-13-2016, 11:13 AM   #17
Amit15
Member
 
Registered: Oct 2016
Posts: 32

Original Poster
Rep: Reputation: Disabled
Wink

Quote:
Originally Posted by Amit15 View Post
What you have done will show some column with checkbox. What I want is when I perform
Code:
select * from tablename
The results that I get in terminal should be displayed in Zenity list like the attachment Capture.png
Which is from the following Link
When I did that
Code:
echo "SELECT bookId,Author,Title,Pulication,Edition,Copies,Date_pur,price,Status FROM bookdetails" | mysql LibraryManagement -N -u root -pmysql123 >> tempAgenda.dat | zenity --list --title="List Records" --text="" --column="bookId" --column="Author" --column="Title" --column="Pulication"--column="Edition" --column="Copies" --column="Date of purchase" --column="price" --column="Status" --height=310 --width=790;
I get the result in attachment Screenshot from picture.png
Also i have attached the tempAgent.dat SreenShot
Please help me out with this too.
 
Old 10-13-2016, 11:37 AM   #18
Amit15
Member
 
Registered: Oct 2016
Posts: 32

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by schneidz View Post
i use process substitution in my example and you are using pipes (which mite work if you didnt redirect the output to a file and away from the pipe -- maybe try tee)
?
I used tee
Code:
echo "SELECT bookId,Author,Title,Pulication,Edition,Copies,Date_pur,price,Status FROM bookdetails" | mysql LibraryManagementSystem -u root -pmysql123 | tee tempAgenda.dat | zenity --list --title="List Records" --text="" --column="bookId" --column="Author" --column="Title" --column="Pulication" --column="Edition" --column="Copies" --column="Date of purchase" --column="price" --column="Status" --height=310 --width=790;
But output is not column wise. Attachement tee.png
Quote:
Originally Posted by schneidz View Post
what happens when you change that line to:
Code:
echo INSERT INTO bookdetails (Author, Title, Pulication, Edition, Copies, Date_pur, price,Status) VALUES ('Author','Title','Publication','Edition',1,'10/13/2016',3.00,'Status');
?
This part is solved
Attached Thumbnails
Click image for larger version

Name:	tee.png
Views:	32
Size:	95.1 KB
ID:	23251  
 
Old 10-13-2016, 12:24 PM   #19
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,672

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
The list data piped into zenity needs a new line as a separator which is why you see a complete row of data for each column including the header. In the example you posted the output of the mysql query is piped to tr and then to zenity.

Assuming the mysql separator is a tab tr replaces it with a new line character.

mysql ... | tr '\t' '\n' | zenity ...
 
Old 10-13-2016, 01:15 PM   #20
Amit15
Member
 
Registered: Oct 2016
Posts: 32

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
The list data piped into zenity needs a new line as a separator which is why you see a complete row of data for each column including the header. In the example you posted the output of the mysql query is piped to tr and then to zenity.

Assuming the mysql separator is a tab tr replaces it with a new line character.

mysql ... | tr '\t' '\n' | zenity ...
Thanks it worked.
But again header is included. I removed tee part still header is included.

Code:
echo "SELECT bookId,Author,Title,Pulication,Edition,Copies,Date_pur,price,Status FROM bookdetails" | mysql LibraryManagementSystem -u root -pmysql123 | tr '\t' '\n' | zenity --list --title="List Records" --text="" --column="bookId" --column="Author" --column="Title" --column="Pulication" --column="Edition" --column="Copies" --column="Date of purchase" --column="price" --column="Status" --height=310 --width=790;
Attached Thumbnails
Click image for larger version

Name:	output.png
Views:	20
Size:	144.7 KB
ID:	23252  
 
Old 10-13-2016, 01:19 PM   #21
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
^ then dont include the column-names (man mysql).

Last edited by schneidz; 10-13-2016 at 01:22 PM.
 
Old 10-14-2016, 12:20 AM   #22
Amit15
Member
 
Registered: Oct 2016
Posts: 32

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by schneidz View Post
^ then dont include the column-names (man mysql).
You mean from Select column_name from tablename
I did that still header is included.
Code:
echo "SELECT * FROM bookdetails" | mysql LibraryManagementSystem -u root -pmysql123 | tr '\t' '\n' | zenity --list --title="List Records" --text="" --column="bookId" --column="Author" --column="Title" --column="Pulication" --column="Edition" --column="Copies" --column="Date of purchase" --column="price" --column="Status" --height=310 --width=790;
 
Old 10-14-2016, 04:11 AM   #23
Amit15
Member
 
Registered: Oct 2016
Posts: 32

Original Poster
Rep: Reputation: Disabled
Guys I found the solution. To skip column names we need to use -N. I did man mysql and there i got this option
--skip-column-names, -N
Code:
echo "SELECT * FROM bookdetails" | mysql -N LibraryManagementSystem -u root -pmysql123 | tr '\t' '\n' | zenity --list --title="List Records" --text="" --column="bookId" --column="Author" --column="Title" --column="Pulication" --column="Edition"--column="Copies" --column="Date of purchase" --column="price" --column="Status" --height=310 --width=790;
;;
Thank you guys for helping me.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help on Insert data to mySQL database aoiregion Linux - Newbie 3 07-22-2014 01:44 AM
Need help on Insert data to phpMyAdmin mySQL database aoiregion Linux - Newbie 4 07-18-2014 04:18 AM
insert openoffice data into mysql sriphp Linux - Software 1 06-02-2009 02:26 AM
segmentation fault when insert data into mysql torontosmallbird Other *NIX 1 08-07-2005 07:13 AM
Insert Data by FORM in MYSQL gruger Linux - Software 0 07-16-2003 12:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration