[Solved] Beginner mysql persistence error

Hello,
I get an error for my mysql persistenc binding.

mySQL: Could not create table for item 'string_weewx_windDir' with statement 'CREATE TABLE Item261 (Time DATETIME, Value VARCHAR(20000), PRIMARY KEY(Time));': Column length too big for column 'Value' (max = 16383); use BLOB or TEXT instead

2020-03-23 11:56:28.346 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Item 'string_weewx_windDir' was not added to the table - removing index

2020-03-23 11:56:28.357 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Could not store item 'string_weewx_windDir' in database with statement 'INSERT INTO Item261 (TIME, VALUE) VALUES(?,?) ON DUPLICATE KEY UPDATE VALUE=?;': Table 'openhabian.Item261' doesn't exist

here is the rule how I set it up:

logInfo("triggered current wind angle to text", MQTT_number_weewx_windDir.state.toString())
    val string_temp = transform("JS", "compassrose.js", MQTT_number_weewx_windDir.state.toString) + "(" +MQTT_number_weewx_windDir.state.toString.split("\\.").get(0) + "°)"
    string_weewx_windDir.postUpdate(string_temp.substring(0,(string_temp.indexOf(')')+1)))```

How do I solve this??

Thanks

Add more logging statements between your rule lines to see if the transformation and substring methods work as intended.

@gitMiguel it#s working see atached log

2020-03-23 13:43:27.435 [INFO ] [el.script.current wind angle to text] - E(90°)

Length of the string is

2020-03-23 13:59:21.381 [INFO ] [el.script.current wind angle to text] - 8

my item definition

String string_weewx_windDir "Windrichtung [%s]" <wind>

@gitMiguel I have done this

mysql:sqltype.string=VARCHAR(16383)

But same error

Try a lot smaller number e.g 200. As this might be something with your server, change logging level of persistence/mysql to DEBUG. Might give us some hints.

Edit: This is the last time I suggest something and you just give the result. I hope to see you to try and find some possible solutions yourself. For starters you should have provided much more info about your system than 3 lines of error. Please search for “Help us to help you”-topic.

@gitMiguel How can I do this? Set my mysql to DEBUG level??

Please search:

Solved with

mysql:sqltype.string=VARCHAR(200)

1 Like