Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table in pandas dataframe df.
Python
<pre lang="Python"> 
	   product_id_x	   product_id_y	   count	   date
    0	288472	         288473	         1	   2016-11-08 04:02:07
    1	288473	         2933696	     1	   2016-11-08 04:02:07
    2	288473	         85694162	     1	   2016-11-08 04:02:07


i want to save this table in mysql database.

but i am getting error.

ValueError: database flavor mysql is not supported


my datatype is str for all the columns.

type(df['product_id_x'][0]) = str
type(df['product_id_y'][0]) = str
type(df['count'][0]) = str
type(df['date'][0]) = str

i don't want to use sqlalchemy or other packages, can anyone tell what's the error here.
Thanks in advance

What I have tried:

i am using MySQLdb package.

import MySQLdb
conn = MySQLdb.connect(host="xxx.xxx.xx.xx", user="name", passwd="pwd", db="dbname")

df.to_sql(con = conn, name = 'sample_insert', if_exists = 'append', flavor = 'mysql', index = False)

i used this query to put it in my db.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900