Home: Perl Programming Help: DBI:
Error importing data



fatmando
Novice

Aug 17, 2006, 9:12 AM


Views: 4665
Error importing data

Hi Guys

Wrote a script which connects to MYSQL and uploads windows eventlog data from a csv file to a database called loganalysis. This seems to work fine until i come across this character ' in the 9th column (Description). As soon as i come across this character the perl script fails.

the line it fails on is as follows

SYS,08/08/2006,11:39:45,KDC,20,Warning,None,,Servername,The currently selected KDC certificate was once valid but now is invalid and no suitable replacement was found. Smartcard logon may not function correctly if this problem is not remedied. Have the system administrator check on the state of the domain's public key infrastructure. The chain status is in the error data.



#!/usr/bin/perl -w

use strict;
use DBI;

my $outsys = "*";

#Upload data to mysql

my $dsn = "DBI:mysql:loganalysis:192.168.0.9";
my $user = '*';
my $password = '*';
my $conn = DBI->connect($dsn,$user,$password) || die "Cannot Connect to Database Server, Reason: " . DBI->errstr;


#Upload Security logs
open(SYS, $outsys);
my @sys = <SYS>;
foreach (@sys) {
my @columes = split(/,/);
my $Description = $columes[9];
$conn->do("INSERT INTO NTSystemLogs(Description)
VALUES(\'$Description\')") || die " Error importing: " . $conn->errstr
};


close SYS;


ERROR:

Error importing: You have an error in your SQL syntax; check the manual that corresponds to your My
SQL server version for the right syntax to use near 's public key infrastructure. The chain status
is in the error data.

Please note that all the columes before comming across this line import without any problem


Any help on avoiding this would be appreciated


KevinR
Veteran


Aug 17, 2006, 11:21 AM


Views: 4664
Re: [fatmando] Error importing data

see your other thread
-------------------------------------------------