You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11 lines
376 B

import pandas as pd
from sqlalchemy import create_engine, text
engine = create_engine('URL DB')
df = pd.read_sql_query(text("SELECT DISTINCT id, name FROM Table"), con = engine.connect(), index_col="id")
for i in list(df.values()):
stmt = text("UPDATE table SET name = :new_name WHERE id =:id").bind_params(new_name = "dasdasdas", id=i.index)
engine.execute(stmt)