Update mysql column using custom python function -


i want update column in database table using function available in python not in mysql. example, have function auto-detects language of string of text , want annotate table of messages autodetected language.

i'd have general way apply python function 1 or more columns in tables, , have lots of data i'd in reasonably time efficient manner.

i'm set class this:

class tableupdate:     def __init__(db_conn, table_name):         #init object         def register_update(column_to_update, update_func, input_columns):         #allow register of multiple column updates     def update():         #run registered updates 

but first wonder, exist in python ecosystem? perhaps somewhere in pandas or sqlalchemy?

to update tables mysql-python package, follow this discussion syntax.

with pandas, process be:

  1. get connection object. mysql, use mysql-python package.
  2. read table pandas (yes, whole , not column)
  3. update values
  4. use dataframe.to_sql push on mysql.

this place start.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -