Ticket #5817: mythburnutf8.diff
File mythburnutf8.diff, 4.3 KB (added by , 17 years ago) |
---|
-
mythplugins/mytharchive/mythburn/scripts/mythburn.py
349 349 350 350 def getDatabaseConnection(): 351 351 """Returns a mySQL connection to mythconverg database.""" 352 return MySQLdb.connect(host=mysql_host, user=mysql_user, passwd=mysql_passwd, db=mysql_db )352 return MySQLdb.connect(host=mysql_host, user=mysql_user, passwd=mysql_passwd, db=mysql_db, init_command='SET CHARACTER SET utf8') 353 353 354 354 ############################################################# 355 # Sets mySQL parameters for getting data in utf8 356 357 def setCursorUtf8( cursor ): 358 """Sets mySQL parameters for getting data in utf8.""" 359 cursor.execute('SET NAMES utf8;') 360 cursor.execute('SET CHARACTER SET utf8;') 361 cursor.execute('SET character_set_connection=utf8;') 362 363 ############################################################# 355 364 # Returns true/false if a given file or path exists. 356 365 357 366 def doesFileExist(file): … … 846 855 db = getDatabaseConnection() 847 856 # create a cursor 848 857 cursor = db.cursor() 858 setCursorUtf8( cursor ) 849 859 # execute SQL statement 850 860 cursor.execute(sqlstatement) 851 861 # get the resultset as a tuple … … 870 880 def saveSetting(name, data): 871 881 db = getDatabaseConnection() 872 882 cursor = db.cursor() 883 setCursorUtf8( cursor ) 873 884 874 885 query = "DELETE from settings " 875 886 query += "WHERE value = '" + name + "' AND hostname = '" + configHostname + "'" … … 893 904 894 905 db = getDatabaseConnection() 895 906 cursor = db.cursor() 907 setCursorUtf8( cursor ) 896 908 897 909 cursor.execute("DELETE from archiveitems;") 898 910 … … 1409 1421 1410 1422 db = getDatabaseConnection() 1411 1423 cursor = db.cursor() 1424 setCursorUtf8( cursor ) 1412 1425 cursor.execute(sqlstatement) 1413 1426 result = cursor.fetchall() 1414 1427 numrows = int(cursor.rowcount) … … 1437 1450 WHERE chanid = '%s' AND starttime = '%s' 1438 1451 AND type IN (0,1) ORDER BY mark""" % (chanid, starttime) 1439 1452 cursor = db.cursor() 1453 setCursorUtf8( cursor ) 1440 1454 # execute SQL statement 1441 1455 cursor.execute(sqlstatement) 1442 1456 if cursor.rowcount > 0: … … 1454 1468 WHERE chanid = '%s' AND starttime = '%s' 1455 1469 AND type = 0 ORDER BY mark""" % (chanid, starttime) 1456 1470 cursor = db.cursor() 1471 setCursorUtf8( cursor ) 1457 1472 # execute SQL statement 1458 1473 cursor.execute(sqlstatement) 1459 1474 # get the resultset as a tuple … … 1481 1496 1482 1497 # connect 1483 1498 db = getDatabaseConnection() 1484 1499 # create a cursor 1485 1500 cursor = db.cursor() 1501 setCursorUtf8( cursor ) 1486 1502 # execute SQL statement 1487 1503 cursor.execute(sqlstatement) 1488 1504 # get the resultset as a tuple … … 1556 1572 WHERE chanid = '%s' AND starttime = '%s' 1557 1573 AND type IN (0,1) ORDER BY mark""" % (chanid, starttime) 1558 1574 cursor = db.cursor() 1575 setCursorUtf8( cursor ) 1559 1576 # execute SQL statement 1560 1577 cursor.execute(sqlstatement) 1561 1578 if cursor.rowcount > 0: … … 1573 1590 WHERE chanid = '%s' AND starttime = '%s' 1574 1591 AND type = 0 ORDER BY mark""" % (chanid, starttime) 1575 1592 cursor = db.cursor() 1593 setCursorUtf8( cursor ) 1576 1594 # execute SQL statement 1577 1595 cursor.execute(sqlstatement) 1578 1596 # get the resultset as a tuple … … 1602 1620 db = getDatabaseConnection() 1603 1621 # create a cursor 1604 1622 cursor = db.cursor() 1623 setCursorUtf8( cursor ) 1605 1624 # execute SQL statement 1606 1625 cursor.execute(sqlstatement) 1607 1626 # get the resultset as a tuple … … 2002 2021 2003 2022 db = getDatabaseConnection() 2004 2023 cursor = db.cursor() 2024 setCursorUtf8( cursor ) 2005 2025 cursor.execute(sqlstatement) 2006 2026 result = cursor.fetchall() 2007 2027 numrows = int(cursor.rowcount)