Answer the question
In order to leave comments, you need to log in
Asterisk - How to extract the log from a text file and add it to the MySQL database, with the addition of a column indicating the SIM card number?
Asterisk+Ubuntu+MySQL
There are a number of commands given to me as instructions. There was a need to add one variable, which entails the adjustment of commands for processing the file. I work in Ubuntu through the command line. The log is written by Asterisk and transferred to MySQL.
Log entry format in a text file: 2014-05-02 11:00:41 -%- datacard1 -%- 777 -%- text
Initially, the working instruction:
CREATE DATABASE `smsinn` CHARACTER SET utf8 COLLATE utf8_general_ci;
use smsinn;
CREATE TABLE LOG (LOGDATE DATE,LOGTIME TIME,NUMBER VARCHAR(50),COMMENT TEXT);
LOAD DATA LOCAL INFILE '/var/log/asterisk/sms.txt' INTO TABLE LOG FIELDS TERMINATED BY '-%-' LINES TERMINATED BY '\n' (@logdate,@unused,@number,@comment) SET LOGDATE=DATE(@logdate),LOGTIME=TIME(@logdate),[email protected],COMMENT=@comment;
SELECT * FROM LOG;
CREATE TABLE LOG (LOGDATE DATE,LOGTIME TIME,DATACARDX INT,NUMBER VARCHAR(50),COMMENT TEXT);
LOAD DATA LOCAL INFILE '/var/log/asterisk/sms.txt' INTO TABLE LOG FIELDS TERMINATED BY '-%-' LINES TERMINATED BY '\n' (@logdate,@unused,@datacardx,@number,@comment) SET LOGDATE=DATE(@logdate),LOGTIME=TIME(@logdate),[email protected],[email protected],COMMENT=@comment;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question