1
data.to_sql('sample_table',mysql_engine, if_exists= 'replace', index = False)

When I run the above line, I get the error:

error_message

Why am I getting this? I am trying to write data to a mysql_db.

3
  • Can you post the full error message and stack trace? Commented Dec 14, 2016 at 9:19
  • I have editied the post and added the snapshot link. Commented Dec 14, 2016 at 10:17
  • In the future please include the full error message as text. Commented Dec 14, 2016 at 10:30

1 Answer 1

2

Your data has a column 'Point_of_reference ' with a trailing space at the end that makes the name invalid.

To fix it, remove all trailing and leading whitespace from your column names:

data.columns = data.columns.str.strip()
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Ian and sorry for posting the question improperly, have not used much of stack overflow, but thanks for the help.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.