-
Notifications
You must be signed in to change notification settings - Fork 88
Description
I trying to query the table from oracle database. My table contains some chines language and german language characters in the data. when I am trying to read the data using python-oracledb i am getting below error.
Error:
File "C:\Users\J\PycharmProjects\pythonProject\Static_Data.py", line 57, in
data = cursor.fetchall()
^^^^^^^^^^^^^^^^^
File "C:\Users\J\AppData\Roaming\Python\Python311\site-packages\oracledb\cursor.py", line 457, in fetchall
row = fetch_next_row(self)
^^^^^^^^^^^^^^^^^^^^
File "src\oracledb\impl/base/cursor.pyx", line 399, in oracledb.base_impl.BaseCursorImpl.fetch_next_row
File "src\oracledb\impl/base/cursor.pyx", line 210, in oracledb.base_impl.BaseCursorImpl._create_row
File "src\oracledb\impl/thick/var.pyx", line 134, in oracledb.thick_impl.ThickVarImpl._get_scalar_value
File "src\oracledb\impl/thick/var.pyx", line 272, in oracledb.thick_impl.ThickVarImpl._transform_element_to_python
File "src\oracledb\impl/thick/utils.pyx", line 284, in oracledb.thick_impl._convert_to_python
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbf in position 0: invalid start byte
Code:
import oracledb
oracledb.init_oracle_client()
conn = oracledb.connect(user="####", password="####", dsn="####")
cursor = conn.cursor()
cursor.execute("SELECT * FROM Table")
data = cursor.fetchall()
data = [row.decode('utf-8'') for row in data]
df = pd.DataFrame(data)
print(df.head())
cursor.close()
conn.close()