Jump to content

connecting a database in perl - on a opensuse 13.1


Recommended Posts

Guest sayhello
Posted

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...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...