Skip to main content

When migrating data from MongoDB to MySQL, I noticed that there is no 'id' column in MongoDB, but there is an 'id' column in MySQL. As a result, I am facing issues when writing data into MySQL. I am looking for assistance in handling the auto-increment column in this scenario. Can anyone provide any guidance or assistance?

Additionally, I am exploring the possibility of using the JDBC Tee processor to handle this situation. Could you please advise me on how to use the JDBC Tee processor in this scenario?

@lakshmi_narayanan_t 

That we can do it in jython evalualtor.

After taking data from mongoDB  , toy can introdcue jython evaluator to create id by using the code snippet.

 

You set the initial value of Id as per your need.

count=0

def incr():
global count
count += 1
return count

# Sample Jython code
for record in sdc.records:
try:
s1 = incr()
record.valuel'id'] = s1
# Write record to processor output
sdc.output.write(record)

except Exception as e:
# Send record to error
sdc.error.write(record, str(e))

 


@Bikram , every time the pipeline runs, it will start the count with 0. So if there is a PK on the table, it will fail.

@lakshmi_narayanan_t Try using JDBCTee processor.

 

 

 


May I know did you manage it using jdbc tee processor , if yes please provide details for future reference for others.


Reply