#!/usr/bin/perl
package db;
require Exporter;
BEGIN {
@ISA = qw(Exporter AutoLoader);
}
@EXPORT = qw();
use strict;
use Data::Dumper qw/Dumper /;
#--------------------------------------------
#Function: getDBINFO
#Scope : private
#功能: 定义一个可供连接的数据库列表,实现对数据库连接的统一管理
#--------------------------------------------
sub getDBINFO
{
my %DBINFO=
(
default =>"xe",
xe =>{
ip =>"10.3.1.100",
port =>"1521",
dbname =>"palm",
user =>"user",
passwd =>"pwd",
dbtype =>"oracle",
},
mysql =>{
ip =>"172.16.1.100",
port =>"3307",
dbname =>"market",
user =>"pwd",
passwd =>"palm\@mkt",
dbtype =>"mysql",
},
);
return %DBINFO;
}
sub new
{
my $this={
};
bless $this;
my $dbinfo=$_[1];
my %DBINFO = $this->getDBINFO();
if ($dbinfo eq ''){
$dbinfo=$DBINFO{
'default'};
}
$this->set_dbinfo($dbinfo);
$this->setAutoCommitOn();
if (exists($DBINFO{
$dbinfo}))
{
my %HASH_TEMP = %{
$DBINFO
Perl连接数据库包
最新推荐文章于 2024-07-13 14:32:00 发布
本文介绍了如何使用Perl语言连接和操作数据库,包括选择合适的数据库连接模块、配置连接参数以及执行SQL查询的基本步骤,帮助Perl开发者更好地进行数据库交互。

最低0.47元/天 解锁文章
2097

被折叠的 条评论
为什么被折叠?



