Dec 28, 2014

[SOLVED] ActiveRecord::StatementInvalid: Mysql2::Error: The used command is not allowed with this MySQL version

hi there...


i just want to share about

direct execution with ActiveRecord on Rails 4

its use effectively to load huge data, so  you need to bypass some needless functions.

sometimes you need to load maybe via CSV or load by SQL, but i recommend to use Local Copy in postgress of load local infile in mysql 

here is the solution 

put localinfile option on database.yml

default: &default
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: root
  password: root
  socket: /var/run/mysqld/mysqld.sock
  local_infile: true


refs:

Read more ...

Dec 27, 2014

Cisco CDR Hex2Ip mysql format

Hi all,

just my note about hex 2 ip conversion for Cisco UCM CDR log.



DELIMITER ;;

DROP FUNCTION IF EXISTS chex2ip;;
CREATE FUNCTION chex2ip (x INTEGER)
  RETURNS varchar(15)
  DETERMINISTIC NO SQL
  BEGIN
    DECLARE x1 varchar(2);
    DECLARE x2 varchar(2);
    DECLARE x3 varchar(2);
    DECLARE x4 varchar(2);
    DECLARE temp varchar(8);
    IF (x<0) THEN
       set temp = SUBSTR(CAST(HEX(x) AS CHAR),9,8);
    ELSE
       set temp = CAST(HEX(x) AS CHAR);
    END IF;
    set x1=substring(temp,1,2);
    set x2=substring(temp,3,2);
    set x3=substring(temp,5,2);
    set x4=substring(temp,7,2);
    RETURN concat(conv(x4,16,10),'.',conv(x3,16,10),'.',conv(x2,16,10),'.',conv(x1,16,10));
  END;;

DELIMITER ;




for other timestamp field, which is use unix, you can convert to mysql-format by :

SELECT from_unixtime(timestamp, '%Y %D %M %h:%i:%s')


here's some refs :

Cisco
Cisco CDR Header
Read more ...