Reputation: 186
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)
Upvotes: 1
Views: 469
Reputation: 186
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. :)
Upvotes: 1