1

Here is the Python code:

from sqlalchemy import create_engine
import pandas as pd

mydb = create_engine("mysql://xx:xx@localhost/xx")
df = pd.DataFrame({'name' : ['User P', 'User Q', 'User R']})
df.to_sql('CARS', con=mydb)

Error:

ProgrammingError: (_mysql_exceptions.ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s, %s)' at line 1") [SQL: INSERT INTO CARS (index, name) VALUES (%s, %s)] [parameters: ((0, 'User P'), (1, 'User Q'), (2, 'User R'))] (Background on this error at: http://sqlalche.me/e/f405)

1 Answer 1

1

Ah, so apparently it seems I had to install PyMySQL (python3 -m pip install PyMySQL)

And a little change here:

mydb = create_engine("mysql+pymysql://xx:xx@localhost/xx")

It worked after this. :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.