LA_
LA_

Reputation: 20419

How to use import_transform of the bulk loader tool?

On data import I should apply the following transformation:

if value:
    return hashlib.sha512(value + salt).hexdigest()

How can I use that with import_transform?

Upvotes: 0

Views: 118

Answers (1)

LA_
LA_

Reputation: 20419

The following helped:

import_transform: "lambda x: hashlib.sha512(x.encode('utf-8') + 'actual_salt_value').hexdigest()"

Upd. the following code handles the case, when field is missed in the upload file:

import_transform: "lambda x: None if x is None or x=='' else hashlib.sha512(x.encode('utf-8') + 'actual_salt_value').hexdigest()"

Upvotes: 1

Related Questions