summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rhnop-client/db.lua19
1 files changed, 14 insertions, 5 deletions
diff --git a/rhnop-client/db.lua b/rhnop-client/db.lua
index 18c925a..bf27bef 100644
--- a/rhnop-client/db.lua
+++ b/rhnop-client/db.lua
@@ -22,14 +22,18 @@
luasql = require "luasql.mysql"
-- for destination database
--- CREATE DATABASE nop
--- GRANT select,insert,update,delete ON nop.* TO 'nopcollectd' IDENTIFIED BY '<password>';
--- GRANT select ON nop.* TO 'nop' IDENTIFIED BY '<password>';
+-- CREATE DATABASE nop CHARACTER SET utf8 COLLATE utf8_unicode_ci;
+-- GRANT select,insert,update,delete ON nop.master TO 'nopcollectd'@'localhost' IDENTIFIED BY '<password>';
+-- GRANT select,insert,update,delete ON nop.standby TO 'nopcollectd'@'localhost';
+-- GRANT select,insert,update ON nop.state TO 'nopsysstated'@'localhost' IDENTIFIED BY '<password>';
+-- GRANT select ON nop.* TO 'nop'@'localhost' IDENTIFIED BY '<password>';
-- USE nop
-- CREATE TABLE IF NOT EXISTS master (timestamp BIGINT UNSIGNED PRIMARY KEY NOT NULL, cart INT NOT NULL, len INT, showtitle VARCHAR(255), title VARCHAR(255), artist VARCHAR(255), album VARCHAR(255), ismusic BOOLEAN);
+-- ALTER TABLE master CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- CREATE TABLE IF NOT EXISTS standby (timestamp BIGINT UNSIGNED PRIMARY KEY NOT NULL, cart INT NOT NULL, len INT, showtitle VARCHAR(255), title VARCHAR(255), artist VARCHAR(255), album VARCHAR(255), ismusic BOOLEAN);
+-- ALTER TABLE standby CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- CREATE TABLE IF NOT EXISTS state (timestamp BIGINT UNSIGNED PRIMARY KEY NOT NULL, state VARCHAR(32));
--- GRANT select,insert,update ON nop.state TO 'nopsysstated' IDENTIFIED BY '<password>';
+-- ALTER TABLE state CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
local db = {}
@@ -50,7 +54,12 @@ function db.init(db, user, pwd, host, port, table)
return nil, err
end
- local ret, err = mydb.con:setautocommit(true)
+ local ret, err = self.con:execute("SET CHARACTER SET utf8")
+ if ret == nil then
+ return nil, err
+ end
+
+ ret, err = mydb.con:setautocommit(true)
if ret == nil then
return nil, err
end