J 将我的库存数据保存在 csv 文件中。我收到一条错误消息,因为我的插入值上有一个特殊字符,我不想处理这些值,因为它们被标记为特殊字符 $" 不再使用它们进行插入。我使用下面的代码:
#!/usr/bin/perl
# PERL MODULES WE WILL BE USING
use DBI;
use DBD::mysql;
# HTTP HEADER
print "Content-type: text/html \n\n";
# CONFIG VARIABLES
$platform = "mysql";
$database = "store";
$host = "localhost";
$port = "3306";
$tablename = "inventory";
$user = "username";
$pw = "password";
# DATA SOURCE NAME
$dsn = "dbi:$platform:$database:$host:$port";
# PERL DBI CONNECT
$connect = DBI->connect($dsn, $user, $pw);
# PREPARE THE QUERY
$query = "INSERT INTO inventory (id, product, quantity) VALUES (DEFAULT, 'tomatoes$"', '4')";
$query_handle = $connect->prepare($query);
# EXECUTE THE QUERY
$query_handle->execute();
如何跳过错误消息并移至下一个插入。