node.js - Mysql encoding error -


i trying insert row in mysql node using mysql2 driver, , getting following error:

running query \"insert outgo (name, monthidmonth, type, distribution, recurrent, amount) values ('penalizări', (select max(idmonth) `month`), '3', '1', '1', '0');\" failed: error: incorrect string value: '\\xc4\\x83ri' column 'name' @ row 1 

the outgo table created this:

create table if not exists `outgo` (    `idoutgo` int unsigned not null auto_increment,    `name` varchar(50) not null,    `apartmentsgroupidapartmentsgroup` int unsigned null,    `outgocolumninfoidoutgocolumn` int unsigned null,    `metering` enum('none','cold_water','hot_water','other') null,    `distribution` enum('manual','person','apartment','surface','consumption', 'automated','heat_surface') null,    `amount` double(14,2) null,    `camount` double(14,2) null,    `costperunit` double(15,3) null,    `unit` varchar(5) null,    `quantity` double(14,2) null,    `diffs` double(14,4) null,    `recurrent` tinyint(1) not null default 0,    `monthidmonth` int unsigned not null,    `type` enum('general','remaining','penality') not null default 'general',    `billidbill` int unsigned null,  engine = innodb;

any idea problem is? string complaining is: "penalizări". schema encoding utf8....

so, in end, found solution: added charset parameter node connection:

var pool  = mysql.createpool({     host     : config.get.mysql.host,     port     : config.get.mysql.port,     user     : config.get.mysql.username,     password : config.get.mysql.password,     database : 'general',     connectionlimit : 50,     queuelimit : 5000,     charset: "utf8_general_ci" }); 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -