Skip to content
Advertisement

How to use googletrans’s Translator on SQLAlchemy object

I am trying to translate couple of columns in cloud MySQL table using googletrans‘s Translator function.

JavaScript

Here I read the MySQL table:

JavaScript

And then here I try to translate it:

JavaScript

But when I try to see if the translation took place using below code, I get no output.

JavaScript

I am new to SQLALchemy and unable to find a solution. Could someone please let me know where I am going wrong and how to access the columns and apply the Translator function.

Advertisement

Answer

If I am not mistaken you want:

JavaScript

Right? You are assigning to data.col1_Translated so it gets overwritten each pass of the cycle.

If that’s not the problem, try:

JavaScript

just to see if anything got translated. If it is, what do you want to do with the translation?

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement