0

everyone.

I am new here, I was recommended by Onare, welp, this will be my first question.

I have a file for ex. "file.log" that contains printing logs.

LINE1: PRINTERNAME | userwhichprinted | ID | DATE | 1 | 1 | - | FROMIP | FILENAME | - | -

LINE2: PRINTERNAME | userwhichprinted | ID | DATE | 1 | 1 | - | FROMIP | FILENAME | - | -

LINE3: PRINTERNAME | userwhichprinted | ID | DATE | 1 | 1 | - | FROMIP | FILENAME | - | -

And so on, actually it is a CUPS Server, someone may be familiarized with it.

I want to make a trigger that put every new line to the database. If there are any more questions needed, let me know, thank you in advance.

1 Answer 1

1

Perhaps something like the following is what you are looking for?

LOAD DATA LOCAL INFILE '/path/to/raw/data/file.log'
INTO TABLE TABLE_NAME
FIELDS TERMINATED BY '|'
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
;
1
  • I did try what you said, however, it doesn't import the file because it doesn't have permissions, I tried changing permissions to 711, 755, 777, X R, and none of them did work, though it gave a different error when I used 711.
    – user70840
    Jul 20, 2015 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy