Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Connecting to OpenOffice Base

by taioba (Acolyte)
on Sep 09, 2008 at 23:26 UTC ( #710215=perlquestion: print w/replies, xml ) Need Help??
taioba has asked for the wisdom of the Perl Monks concerning the following question:

Hi! I am trying to connect to an OppenOffice database using Perl. I suspect I could do this through ODBC, but I don't know which driver to use.

I'm using Active Perl 5.10.x installed in a Windows XP machine, but I'll have to implement this code in a machine running Mac OS X, hence the need to migrate to OpenOffice.

I have the code working for an Access database. One of the operations is simply to store the database information in a hash (see example below, targeting the Access database.)
Any help is greatly appreciated.

Best wishes.
sub dbQuery { my ($queryStr) = @_; my $dbObject = DBI->connect("dbi:ODBC:driver=Microsoft Access Driv +er (*.mdb, *.accdb); dbq=$logHsh{dbPath}", {RaiseError => 1}) || errMsg("Cannot connect to database.\n$DBI::e +rrstr"); my $dbQuery = $dbObject->prepare($queryStr, {RaiseError => 1}) || +errMsg("Couldn't prepare querying statement.\n$DBI::errstr"); $dbQuery->execute || errMsg("Error fetching data.\n$DBI::errstr"); my %dbHsh; while (my ($hshKey, $hshRec) = $dbQuery->fetchrow_array) { $dbHsh{$hshKey} = $hshRec; } $dbObject->disconnect; return %dbHsh; }

Replies are listed 'Best First'.
Re: Connecting to OpenOffice Base
by grep (Monsignor) on Sep 10, 2008 at 00:51 UTC
    I would use an actual DSN from ODBC. It looks like you're using handcrafted DSN for Access.

    Setup DSN Instructions. Then you'll have a DSN name to use in your DBI string.

    $dbh = DBI->connect('dbi:ODBC:DSN', 'user', 'password');

    Note: If you don't see Open Office Base as a option for a data source check out the Open Office Website for ODBC drivers.

    One dead unjugged rabbit fish later...
Re: Connecting to OpenOffice Base
by Sagacity (Monk) on Sep 10, 2008 at 02:46 UTC

    In addition to grep's correct reference to the open office website, it appears that they are suggesting you use the Java Access Bridge as your interface handler.
    I found this reference on the open office website
    Java Access Bridge

    Since you haven't elaborated on the desired outcome of your system, I can only bring up the questions based on my own experiences. I hope you do well on this project, and hope that the links and suggestions/questions will help get you to your goal. It looks like you are destined to use the Java Bridge, but consider the following:

    Good Luck!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://710215]
Approved by ikegami
and dust plays in a shaft of sunlight...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2018-04-22 17:36 GMT
Find Nodes?
    Voting Booth?