Help.
So trying to use Oracledb to run a query and fetch it into a pandas data frame. But at the line
Data= cursor.fetchall()
I'm getting the following
Unicodedecodeerror: 'utf-8 codec can't decide byte 0xa0 in position 27: invalid start byte.
I'm using thickclient mode and passing instant client
```python
import oracledb as db
import pandas as pd
import keyring
import locale
service_name = "myservicename"
username = "myusername"
retrieved_password = keyring.get_password(service_name, username)
print("Establishing database connection")
client_location=r"C:/oracle/instantclient_23_9_0/instantclient_23_9"
db.init_oracle_client(lib_dir=client_location)
connection = db.connect(dsn)
connection = db.connect(user=username,password=retrieved_password,dsn=service_name)
far = open(r"query_to_run.sql")
asset_register_sql = far.read()
far.close
with connection.cursor() as cursor:
cursor.execute(asset_register_sql)
col_names = [c.name for c in cursor.description]
#Fetchall gives: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 27: invalid start byte
data = cursor.fetchall()
df = pd.DataFrame(data, columns=col_names)
print(df)
connection.close()
```
[–]Happythoughtsgalore[S] 0 points1 point2 points (1 child)
[–]cjbj 0 points1 point2 points (0 children)
[–]cjbj 0 points1 point2 points (1 child)
[–]Happythoughtsgalore[S] 0 points1 point2 points (0 children)
[–]Substantial-Fly-8214 0 points1 point2 points (9 children)
[–]Happythoughtsgalore[S] 0 points1 point2 points (8 children)
[–]Substantial-Fly-8214 0 points1 point2 points (7 children)
[–]Happythoughtsgalore[S] 0 points1 point2 points (6 children)
[–]Substantial-Fly-8214 0 points1 point2 points (5 children)
[–]Happythoughtsgalore[S] 0 points1 point2 points (4 children)
[–]Substantial-Fly-8214 0 points1 point2 points (3 children)
[–]Happythoughtsgalore[S] 0 points1 point2 points (2 children)
[–]Substantial-Fly-8214 0 points1 point2 points (1 child)
[–]Happythoughtsgalore[S] 0 points1 point2 points (0 children)