CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
connecting a database in perl - on a opensuse 13.1

 



dilbert
User

May 25, 2014, 11:36 AM

Post #1 of 2 (3613 views)
connecting a database in perl - on a opensuse 13.1 Can't Post

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 }



Laurent_R
Veteran / Moderator

May 25, 2014, 11:22 PM

Post #2 of 2 (3370 views)
Re: [dilbert] connecting a database in perl - on a opensuse 13.1 [In reply to] Can't Post

I can't see any reason why you could not use the installed version of your mysql database (except for possible version incompatibilities between mysql and your database DBI driver).


(This post was edited by Laurent_R on May 25, 2014, 11:24 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives