LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 05-25-2010, 04:50 AM   #1
LadyAnne
LQ Newbie
 
Registered: May 2010
Posts: 3

Rep: Reputation: 0
Write a script to extract information from db tables


Hi

I want to write a script that will extract information from a db table and store that information to a csv file.

Basically, I have imported data into a table, I want to save this data to a csv file for later processing.

How do I connect to the db and extraxt information from the table?

Thank you
 
Old 05-25-2010, 05:00 AM   #2
longbow0
LQ Newbie
 
Registered: Jul 2005
Distribution: Debian
Posts: 20

Rep: Reputation: 2
It depends:

1. Which scripts you prefer, Perl, Python or other?
2. What database you are working on, MySQL, SQLite or something else?

Export data from database table into csv is not necessary since many script languages provide database interfaces. For instance, the DBI for Perl.

Last edited by longbow0; 05-25-2010 at 05:03 AM.
 
Old 05-25-2010, 05:01 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,499

Rep: Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867
hmmm ... db ... Mysql, Oracle, DB2 ... and the list goes on

You will need to advise the database you are dealing with (I could assume mysql but long track if i am wrong) and you need to also tell us what you
would like to use, ie bash, perl, etc
 
Old 05-25-2010, 05:02 AM   #4
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,299

Rep: Reputation: 102Reputation: 102
use this


For ORACLE
Code:
sqlplus username/password@database_name << END
....
Your SQL Commands
....
END
OR-OR

Code:
sqlplus username/password@database_name @ abc.sql
where abc.sql contains your SQL commands

For MySQL
Code:
mysql -u username -p password database -e "Your SQL Commands"

Last edited by vikas027; 05-25-2010 at 05:02 AM. Reason: missed something
 
  


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
How to extract information element from Beacon Frame. Mr.J Linux - Wireless Networking 0 04-25-2009 09:49 PM
Extract Local User Information borisys Red Hat 1 02-20-2009 10:53 AM
How to extract information from a large data pool with AWK script? underskinned Programming 2 11-23-2006 09:26 PM
Bash: Extract Title Information From Playlist xxfunkxx Linux - Newbie 5 07-28-2004 02:31 AM
Extract information from mail boxes pcwulf Linux - Software 0 06-20-2004 08:04 PM


All times are GMT -5. The time now is 01:27 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration