注册会员会员登录

当前位置:首页 > 技术分享

Genesis perl往数据库mysql写数据

发布时间:2017-01-07 09:39:00 点击:
#!/bin/perl -w
use strict;   
use Tk;   
use DBI;
my $dbname = "project_status";
my $location = "localhost";
my $port = "3306"; #这是mysql的缺省
my $database = "DBI:mysql:$dbname:$location:$port";
my $db_user = "root"; #数据库的账号
my $db_pass = ""; #密码
my $dbh = DBI->connect($database,$db_user,$db_pass);
my $sql = "update project_status_user set site = 'chris' where id = 1"; #更新mysql的数据
my $sth = $dbh->prepare($sql);#结果保存在$sth中
$sth->execute() or die "无法执行SQL语句:$dbh->errstr";
$sth->finish;
$dbh->disconnect; #断开数据库连接
    文章评论
    内容:
     
    惠州韦达软件技术服务有限公司:
    电话:15728891693 /18688300180 邮箱:2933839366@qq.com QQ: 2933839366 网址:www.qhscript.com