Pandora FMS Community

spaces in group name, agent name and etc in mysql db (&#x20)

taraska90 · 14 abr 2017, 16:58 · 4 mensajes · 83 visitas

  1. Inicio del debate

    Hello community, I noticed that in db when I create some items with spaces in name, that items appears with unicode hex character  . For example: mysql> select nombre from tgrupo where id_grupo='191'; +------------------------------+ | nombre                      | +------------------------------+ | Любанский МУ            | +------------------------------+ 1 row in set (0.00 sec) Please give me advice how can I decode this character in python? For example I want to create dependence with group name and group id (there is no api function as I know): import MySQLdb db = MySQLdb.connect(host="localhost", user="root", passwd="pandora", db="pandora", charset='utf8') id='Любанский МУ' sql="select id_grupo from tgrupo where nombre='%s'" % id cursor.execute(sql) 0L print cursor.fetchall() () But: id = 'Любанский МУ' sql="select id_grupo from tgrupo where nombre='%s'" % id cursor.execute(sql) print cursor.fetchall() ((191,),)

  2. Hello taraska90, I don't know how could you decode that in python, maybe using regular expressions may be an option (substitute " " for blank character maybe). Kind regards, Antonio.

  3. Okay, lets forget about python. Why all spaces in db replaced with ? P.s. This is Unicode Hex Character Code for space

  4. Hello taraska90, That's the normal behaviour, if you take a look at other tables you will find that syntax on some other fields. Kind regards, Antonio.

Entra en tu cuenta para publicar.