0

I want to replace database table values with dataframe values. Need your advice !

I have a database with table Data as follows:

Ref    Text   Queue  EmailID    
1      ABC    PQ     [email protected]

and a dataframe : df['EmailID','Queue'] as follows:

 Queue  EmailID    
 GQ     [email protected]

I want to replace EmailID, Queue from Data table with dataframe values in python.

I have a code as follows:

cur.execute ("""UPDATE tblops.uploadmanagement SET Queue=%s WHERE EmailID=%s""", (df['Journey1'], df['EmailID']))

I am getting following errors:

The SQL contains 0 parameter markers, but 2 parameters were supplied', 'HY000'

Expected :

Ref    Text   Queue  EmailID    
1      ABC    GQ     [email protected]

I have gone through following links:

Writing Python Dataframe to MSSQL Table

pandas to sql seriver

http://www.mysqltutorial.org/python-mysql-insert/

Need your advice !

9
  • I have attempted editing for links and table/dataframe but could not apply it. Commented Jan 17, 2019 at 11:41
  • It needs to be '%s' not %s for the parameter markers. I'm not sure it will work, though, supplying whole Series objects. Commented Jan 17, 2019 at 11:48
  • In addition, adding numpy integers to an SQLite database results in BLOBs. I don't know if this will apply in MySQL. Commented Jan 17, 2019 at 12:00
  • @roganjosh for '%s' it gives error - Error converting data type varchar to bigint Commented Jan 17, 2019 at 12:40
  • I did say that I didn't think it would work. But now you actually have a query string that allows you to insert parameters, which was your first issue. Commented Jan 17, 2019 at 12:41

0

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.