I am using cx_Oracle to fetch some data stored in Arabic characters from Oracle database. Below is how I try to connect to the database. However when I try to print the results specially those column stored in Arabic I get something like "?????" which seems to me that the data was not coded properly. However, I tried to print random Arabic string in Python it went alright which indicates the problem from the way I am pulling data from the database connection = cx_Oracle.connect("username, password, instanceName) wells = getWells(connection)
def getWells(conn): cursor = conn.cursor() wells = [] cursor.execute(sql) clmns = len(cursor.description) for row in cursor.fetchall(): print row well = {} for i in range(0, clmns): if type(row[i]) is not datetime.datetime: well[cursor.description[i][0]] = row[i] else: well[cursor.description[i][0]] = row[i].isoformat() wells.append(well) cursor.close() connection.close() return wells
Aucun commentaire:
Enregistrer un commentaire