Perl读取excel插入mysql数据库错误 DBD::mysql::st execute failed: You have an error in your SQL syntax

使用Perl读取excel(.xls)文件,然后导入数据库,一直出现如下问题,用短的测试也没有问题,苦恼了一天==,根据错误提示把提示的某些项删掉测试,发现只要有Function就一条都插入不进来,单独update它也不行,试来试去最后发现,这原来是SQL里的一个函数,是个关键字,所以不能用语句对其进行插入。

错误描述:
DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘Function, Reference,
Sequence, Length, MolecularWeight, StructureVa’ at line 3 at E:\Bioinformatics\PaCRISPR\perl-data-test\Spreadsheet-ParseExcel-0.59\examples\read_insert.pl line 120.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘Function, Reference,
Sequence, Length, MolecularWeight, StructureVa’ at line 3 at E:\Bioinformatics\PaCRISPR\perl-data-test\Spreadsheet-ParseExcel-0.59\examples\read_insert.pl line 120.
在这里插入图片描述

两种解决方法:
  1. 把Function关键字换掉,别用这个名字了。
  2. 语句中关键字使用'Function'将其括起来,符号是键盘~下边那个引号,不是平时使用的那个,要注意一下。正确代码如下图所示。
    在这里插入图片描述
最后附上关键字的一个连接:http://www.postgres.cn/docs/9.3/sql-keywords-appendix.html

PS:下章参考一下Perl读取excel插入mysql数据库的代码~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值