Perl DBD :: SQLite :: db失败:语法错误

时间:2018-11-02 19:43:35

标签: multithreading sqlite perl

我正在开发一个Perl脚本,以使用线程和DBD :: SQLite来查询PasteBin API,以存储信息供以后使用。

运行脚本时,出现以下错误:

xAxis: { categories: ['March', 'April', 'May', 'June'], labels: { style: { color: 'black', fontSize:'15px' }, formatter: function(){ return '<span style="margin-right: 9px">' + this.chart.series[0].options.stack + '</span><span>' + this.chart.series[1].options.stack + '</span><br /><div style="text-align:center"> <br />' + this.value + '</div> ' }, useHTML: true }
                                                                                                                                                               DBD::SQLite::db do failed: near "day": syntax error at getpaste.pl line 113.

使用我的代码进行调试,这就是我在Thread 3 terminated abnormally: DBD::SQLite::db do failed: near "day": syntax error at getpaste.pl line 113.中看到的内容:

thread 3

如果我必须进行有根据的猜测,它会在enum _Days { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday } class HeadingItem implements ListItem { String _weekday; final int time; final DocumentReference reference; set day(String weekday) { var value = _Days.values[int.parse(weekday) - 1].toString(); var idx = value.indexOf(".") + 1; var result = value.substring(idx, value.length); _weekday = result; } String get day { return _weekday; } HeadingItem.fromMap(Map<String, dynamic> map, {this.reference}) : assert(map['day'] != null), assert(map['time'] != null), day = map['day'], // 'day' isn't a field in the enclosing class <--- this is the error that im stuck on... time = map['time']; HeadingItem.fromSnapshot(DocumentSnapshot snapshot) : this.fromMap(snapshot.data, reference: snapshot.reference); } 爆炸

这是与我的代码有关的一大部分:

String get day {

在这种情况下,第113行是sub threadCheckKey { my ($url, $key) = @_; my $fullURL = $url.$key; my @flaggedRegex = (); my $date = strftime "%D", localtime; my @data = (); my $thread = threads->create(sub { my $dbConnection = openDB(); open(GET_DATA, "curl -s " . $fullURL . " -k 2>&1 |") or die("$!"); open(WRITE_FILE, ">", $key . ".txt") or die("$!"); while(my $line = <GET_DATA>) { print WRITE_FILE $line; foreach my $regex(@regexs) { if($line =~ m/$regex/) { if(!($regex ~~ @flaggedRegex)) { push(@flaggedRegex, $regex); } } } } close(WRITE_FILE); close(GET_DATA); open(READ_FILE, $key . ".txt") or die("$!"); while(my $line = <READ_FILE>) { push(@data, $line); } close(READ_FILE); my $updateRow = qq(UPDATE $tables[0] set data = \'@data\', date = \'$date\', regex = \'@flaggedRegex\' where pastekey = \'$key\'); my $executeRowUpdate = $dbConnection->do($updateRow); if($executeRowUpdate < 0) { print $DBI::errstr; } ,知道Perl的确是在抱怨我的UPDATE语句。

我在哪里出错呢?与任何与sql相关的交互时,我还是一个新手。

1 个答案:

答案 0 :(得分:1)

您需要记录生成的$updateRow,然后查看它并查看问题所在。没有那个,没人知道。

ikegami在上面的评论中提到的其他问题可能值得关注针对其各个方面的新问题。正如您所发现的,https://codereview.stackexchange.com/不适用于有错误的代码。但是考虑到所有注入问题,可能是时候尝试https://security.stackexchange.com/

如果您解决了这些问题,也许您的错误也会消失。是否可以,但是值得尝试。