K
K
Kapatblxa02014-05-02 14:53:42
MySQL
Kapatblxa0, 2014-05-02 14:53:42

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;

Tried to add datacardx, this is what happened
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;

Error: ERROR 1148 (42000): The used command is not allowed with this MySQL version

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Ovoshlook, 2014-08-04
@Ovoshlook

So you swear on MySQL. Says mysql version is not supported.
The syntax in any asterisk query to MySQL is a MySQL Query.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question