CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Dumping/Exporting table to a file via Perl DBI

 



esenlik
New User

Mar 10, 2010, 11:16 AM

Post #1 of 4 (2163 views)
Dumping/Exporting table to a file via Perl DBI Can't Post

Hi,

I want to dump a 'select' result of a "Huge" table in to a file (csv or not) using the perl dbi module.
Currently I am in the process of moving all my db calls from system to dbi calls to effectively handle errors and such.. I am stuck on figuring out how to use dbi call effectively to do the below statement.

For now its doing it via system call:

Code
 system("psql -U timadbo -c 'SELECT * FROM $summary;' timadb > $output  ");


I dont want to use the fethrow b/c I believe it will take longer to process than just dumping it directly

Code
 while (@data = $sth->fetchrow_array())


Does anybody have solution or pointer for me on how to export the results to an output file using dbi on postgres?


Nila
User


Mar 10, 2010, 9:42 PM

Post #2 of 4 (2152 views)
Re: [esenlik] Dumping/Exporting table to a file via Perl DBI [In reply to] Can't Post

Try this,


Code
my $ary_ref  = $db->selectall_arrayref("select * from table_name"); 
print FH1 Dumper \$ary_ref;



FishMonger
Veteran / Moderator

Mar 11, 2010, 5:44 AM

Post #3 of 4 (2147 views)
Re: [Nila] Dumping/Exporting table to a file via Perl DBI [In reply to] Can't Post

Cross posted
http://forums.devshed.com/perl-programming-6/dumping-exporting-table-to-a-file-via-perl-dbi-683601.html


esenlik
New User

Mar 11, 2010, 11:03 AM

Post #4 of 4 (2140 views)
Re: [Nila] Dumping/Exporting table to a file via Perl DBI [In reply to] Can't Post

Thank you Nila for your help

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives