Perl script to output to file

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Perl script to output to file

Bill McCormick-4
 From the sqlite command line interface, the .output command will output
the result of a query to a file.

How can I do this from a Perl script? I'm not finding any built-in
facility to do this in the Perl module.

I found this
(http://members.toast.net/strycher/perl/example_dbi_sql.htm), but I'm
thinking maybe there's a monk out there that has already made a really
cool wheel.

Thanks!!
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Perl script to output to file

Simon Slavin-3

On 1 Feb 2012, at 4:20pm, Bill McCormick wrote:

> From the sqlite command line interface, the .output command will output the result of a query to a file.
>
> How can I do this from a Perl script? I'm not finding any built-in facility to do this in the Perl module.

The '.output' command is written into the sqlite3 application.  It's not part of the SQLite library.  Just use Perl's file-handling functions to write text to a text file.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Perl script to output to file

Puneet Kishor-2
In reply to this post by Bill McCormick-4

On Feb 1, 2012, at 10:20 AM, Bill McCormick wrote:

> From the sqlite command line interface, the .output command will output the result of a query to a file.
>
> How can I do this from a Perl script? I'm not finding any built-in facility to do this in the Perl module.
>


pseudocode ahead

1. open filehandle $fh
2. prepare and execute query $query
3. write results to filehandle `say $fh $query`
4. close filehandle $fh

--
Puneet Kishor

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users