Tak jsem se dostal ve svem putovani Py svetem k dalsi zahade.<br><br>pokousim se provest zapis do tabulky ovsem pokud string obsahuje nejake nevhodne znaky tak se to neprovede a prevest mi to proste nejde.<br><br>provadim toto:<br>
<br>import _mysql<br>import MySQLdb<br><br>conn = MySQLdb.connect (host = "localhost",<br> user = "root",<br> passwd = "",<br> db = "databaze")<br>
<br>conn.set_character_set('utf8')<br>spojeni = conn.cursor ()<br>x='url=\xa1[img'<br><br>spojeni.execute("UPDATE databaze.phpbb3_posts SET post_text = '%s' WHERE phpbb3_posts.post_id =637797 LIMIT 1 ;"%x)<br>
spojeni.close()<br><br>a zde dostanu hlaseni <br>"Warning: Incorrect string value: '\xA1[img' for column 'post_text' at row 1"<br>coz mi teda neni jasne string jako string. navic toto jsem z db prve precetl a ted to potrebuju jen vratit zpet na puvodni misto ve tvaru v jakem to tam bylo. <br>
<br>No rekneme ze tedy neni slusne do databaze cpat unicode ovsem ono to spadne i u prevodu<br> <br>print x.decode('utf-8')<br>
<br>mi zakrici: UnicodeDecodeError: 'utf8' codec can't decode byte 0xa1 in position 4: unexpected code byte<br>takze ted nejak nevim kudy kam.<br><br>