Python Forum
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 error from Mysql call
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 error from Mysql call
#1
Python3, Ubuntu 20.04

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92

When querying the MySQL database I receive this error, the code was working under Python2.7 but not in Python3.

appointments = App_Connection().Query_All("SELECT * FROM `ea_appointments` WHERE `id` > '%s'" % (record_num,))


class App_Connection(object):
    def __init__(self, host="xx.xxx.x.xxx", user="_app", passwd="", db="appoint"):
        self.host = host
        self.user = user
        self.passwd = passwd
        self.dbc = db
        self.connection()

    def connection(self):
        self.connection = MySQLdb.connect(self.host, self.user, self.passwd, self.dbc)

    def Query_All(self, sql_statement):
        cursor = self.connection.cursor()
        cursor.execute(sql_statement)
        result = cursor.fetchall()
        cursor.close()
        return result

    def Query_One(self, sql_statement):
        cursor = self.connection.cursor()
        cursor.execute(sql_statement)
        result = cursor.fetchone()
        cursor.close()
        return result

    def Commit(self, sql_statement):
        cursor = self.connection.cursor()
        cursor.execute(sql_statement)
        self.connection.commit()
        cursor.close()
buran write Apr-27-2021, 01:48 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have re[laced quote tags with python tags for you.
See BBcode help for more info.
Reply
#2
This must be a MySQLdb thing as I have changed module to
import pymysql
and it works as expected
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Mysql and mysql.connector error lostintime 2 662 Oct-03-2023, 10:25 PM
Last Post: lostintime
  UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd2 in position 16: invalid cont Melcu54 3 4,914 Mar-26-2023, 12:12 PM
Last Post: Gribouillis
  Decode string ? JohnnyCoffee 1 813 Jan-11-2023, 12:29 AM
Last Post: bowlofred
  [SOLVED] [Debian] UnicodeEncodeError: 'ascii' codec Winfried 1 1,018 Nov-16-2022, 11:41 AM
Last Post: Winfried
  UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 34: character Melcu54 7 18,835 Sep-26-2022, 10:09 AM
Last Post: Melcu54
  Byte Error when working with APIs Oshadha 2 1,007 Jul-05-2022, 05:23 AM
Last Post: deanhystad
  Mysql Syntax error in pymysql ilknurg 4 2,344 May-18-2022, 06:50 AM
Last Post: ibreeden
  Mysql error message: Lost connection to MySQL server during query tomtom 6 15,987 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  mySQL Database error not resolving. cybertooth 2 3,195 Aug-30-2021, 05:45 PM
Last Post: ibreeden
  MYSQL.CONNECTOR ERROR DB1 8 3,827 Jul-23-2021, 03:31 AM
Last Post: DB1

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020