rory oconnor [[EMAIL PROTECTED]] quoth: *>I'm trying to write some queries to export MySQL information to a file, *>and I'm a bit of a newbie. I'm querying the database for fieldnames, *>and then field data. then I want to write the data to a file in a sort *>of key:value format: *> *>and I guess I can do a second query to select the data, but I am stuck *>at how to write them out in sort of key-value pairs. and i'm not even *>sure this is the most efficient way.
I'm not sure what you had there but try the following with your fields and query inserted where applicable. #!/usr/bin/perl -w use DBI; use strict; open DBSET,"> dboutput" or die "can't open dboutput: $!"; my $dbh = DBI->connect( "dbi:mysql:dbname", "username", "passwd" ); my $sth = $dbh->prepare( " SELECT field1, field2 FROM db WHERE field1 = '' " ); $sth->execute(); while ( my ($field1,$field2) = $sth->fetchrow_array ) { print DBSET "$field1 is a part of $field2\n"; } $dbh->disconnect; close DBSET; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]