MySQL Forums
Forum List  »  Perl

SQL to XML using DBIx::XML_RDB >> Can't connect to the database
Posted by: lauragarcia_b
Date: June 20, 2006 09:21PM

Hi all,

I am having a weird problem using the DBIx:: XML_RDB module, which should return the results of a SQL select statement as well-formed XML.

I can't connect to the database. I keep on getting a 'Can't call method "DoSql" on an undefined value' error and I can't see where the problem is because I connect to the database using the DBI module with no problems.

Has anyone used this module?

Here is the code I am using. Thanks a lot in advance for any help or thoughts.


laura



#!/usr/bin/perl -w

#########################################################
# Check platform
#########################################################
if ($0=~m#^(.*)\\#){ $execDir = "$1"; } # Win/DOS
elsif ($0=~m#^(.*)/# ){ $execDir = "$1"; } # Unix
else {`pwd` =~ /(.*)/; $execDir = "$1"; } # Unix

# Get DB Info
require "$execDir/info.pl";

#FYI
#$database = " mydatabase";
#$data_source = "dbi:mysql:$database;host=localhost";

# Use CGI Perl module to output any error msgs to browser
use CGI::Carp qw(fatalsToBrowser);

use DBIx::XML_RDB;

my $xmlout = DBIx::XML_RDB->new($data_source, 'mysql', $mySqlUsername, $mySqlPassword {'RaiseError' => 1, 'PrintError' => 1});

$xmlout->DoSql("SELECT subm_id, subm_name FROM submissions");

open(XML, ">submissions.xml") or die "Could not open file for writing: $! \n";

print XML $xmlout->GetData;

close XML or die "Error closing file: $!\n";

Options: ReplyQuote


Subject
Written By
Posted
SQL to XML using DBIx::XML_RDB >> Can't connect to the database
June 20, 2006 09:21PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.