#!/usr/bin/perl -w use strict; use encoding 'utf-8'; use DBI; my $conn = DBI->connect("DBI:mysql:database=riskiq_test;mysql_enable_utf8=1", "ck", "ck", { RaiseError => 1, AutoCommit => 1 }); $conn->do("delete from test_model where test_id = 102"); my $stmt = $conn->prepare("insert into test_model (test_id, name) values (?, ?)"); $stmt->execute(102, "不一样的星期五"); #$conn->commit(); $stmt = $conn->prepare("select test_id, name from test_model where test_id >= 100"); $stmt->execute(); while (my $row = $stmt->fetchrow_hashref()) { printf "%10d %s\n", $row->{test_id}, $row->{name}; } $conn->disconnect();