Menu

Mysql_persistence

jef2000 Damago

Here's a config example:

<persistence type="mysql" host="localhost" user="linknxtest" pass=""
    db="linknx_test" table="persist" logtable="log" />

Queries executed by linknx looks like:

INSERT INTO `

` (`object`, `value`) VALUES (<object_id>', '<value>')
    ON DUPLICATE KEY UPDATE `value` = <value>';
INSERT INTO `<log_table>` (ts, object, value) VALUES (NOW(), '<object_id>','<value>');

And an example Mysql tables that would work:

CREATE TABLE `log` (
  `ts` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `object` varchar(256) NOT NULL,
  `value` varchar(256) NOT NULL,
  KEY `object` (`object`,`ts`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `persist` (
  `object` varchar(256) NOT NULL,
  `value` varchar(256) NOT NULL,
  `ts` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  PRIMARY KEY  (`object`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Notes:
1. logging into "log" logtable will only be active for objects whose definition contains log="true"
2. writes into "persist" table will only be performed for objectwith whose definition contains init="persist" attribute
2. MySql persistance is only active when linknx was compiled with --with-mysql=/usr/bin/mysql_config (give that option to the ./configure command).


Related

Wiki: Services_section

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.