connecting a database in perl - on a opensuse 13.1

  • Thread starter Thread starter sayhello
  • Start date Start date
S

sayhello

i have a Perl program that reads XML data and posts it into a MySQL database.

some questions: i am pretty new to perl


i do lots of work with PHP
therfore i have installed an
Apache
Mysql
PHPMyadmin on my opensuse 13.1

all works great!!
[ and the phpmyadmin is allso available http://localhost/phpMyAdmin/ ]


Question - the allready installed mysql database can be usef for the perl-job too, can ´t it!?


i run opensuse 13.1

i need to get the data into the database -

first of all i have to parse the planet - openstreetmap - data and subsequently pass it over to the mysql db.

note- can i use the allready installed database?


see the code - the perl code that uses DBI


Code:
#!/usr/bin/perl
use strict ;
use DBI;
use XML::Twig;

# prepare database
my $dbh=dbh(); # connect
init();
$dbh->do('USE db123');
#$dbh->do('DELETE FROM pois');

# sql
my $sql = 'REPLACE INTO pois VALUES (?,?,?,?,?,?)';
my $sth = $dbh->prepare($sql);

# set up handler
my $t = XML::Twig->new(
twig_handlers => { 'node' => \&node }
i hope that i was able to tell you my problems and make clear what i need to know

if not - let me know

look forward to hear form you

greetings

Continue reading...
 
Back
Top