[Python] pandas dataframe.to_sql IntergrityError [duplicate]

Discussão em 'Python' iniciado por Stack, Março 1, 2025.

  1. Stack

    Stack Membro Participativo

    I'm very much stuck in here.

    I want to send pandas dataframe to MySQL servers.

    df.to_sql('table_name',
    if_exists='append',
    con=connection_string,
    index=False)


    it kept showing me the error:

    (pymysql.err.IntegrityError) (1062, "Duplicate entry '(value)' for key '(table).PRIMARY'")


    all the value in Primary key column is unique, and there are no duplicated.

    Continue reading...

Compartilhe esta Página