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:
- get connection object. mysql, use mysql-python package.
- read table pandas (yes, whole , not column)
- update values
- use dataframe.to_sql push on mysql.
this place start.
Comments
Post a Comment