Python MongoDB Lock Exception

I am transferring data from oracle to Mongo DB using python, and when moving I can read the clob object using clob.read (), but when pasting into mongo DB it throws an exception saying

Traceback (last call last): File "test.py", line 39, in db.test234.insert (i) File "C: \ Python27 \ lib \ sitepackages \ pymongo \ collection.py", line 409, insert gen ( ), check_keys, self.uuid_subtype, client)
InvalidStringData: lines in documents must be valid UTF-8: "Malicious Driver" | ----------------------- \ r \ n \ r \ n

This is an attempt (Malicious Attack Driver), which includes wrapping procedures to provide a test script infrastructure for launching various attack tools, vulnerability scanners such as hacker tools. The goal is to provide common APIs for all protocols that can launch attack / testing from a remote device.

'REVIEW_DESCRIPTION', type 'cx_Oracle.CLOB', -1, 4000, 0, 0, 0 

checked many forums and stack overflows, couldn’t find an exact solution to the problem, tried parameters such as clob data encoding, which still threw the same exception

+5
source share
1 answer

You need to get the data in UTF8, so you need to know what encoding is used in Oracle DB. Decode first and then encode to UTF8. For example, if data is written to latin1 in Oracle DB:

 unicode_representation = oracle_representation.decode('latin1') utf8_representation = unicode_representation.encode('utf8') 

Now you can save utf8_representation .

0
source

Source: https://habr.com/ru/post/1209611/


All Articles