Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

This question already has an answer here:

I'm trying to insert some data into the table "billing accounts" and I tried the given below way. There was no error, how ever the data is not getting inserted into the table. am I doing anything wrong here? I am using python's mysql.connector module for this work.

def billingaccounts(self,stag,prod):

    print "Updating the consilidated daily bills for stag and prod"
    cursor = self.testdb.cursor()
    stag = 87
    prod = 45
    now = '2016-06-03'
    to = 84
    cursor.execute('INSERT INTO iaas.billing_accounts (date, staging_account, production_acount, total) VALUES (%s, %s, %s, %s)',(now,stag,prod,to))
share|improve this question

marked as duplicate by Ocaso Protal, Community Jun 30 at 7:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
I don't know this specific module, but are you certain it is in autocommit mode? Or shouldn't you commit after your insert? – spectras Jun 30 at 7:27
    
That helped thank you so much – Aditya_softwaredeveloper Jun 30 at 7:36
up vote 1 down vote accepted

You have to send a commit to the server to see the changes.

https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlconnection-commit.html

share|improve this answer
    
Thanks that helped – Aditya_softwaredeveloper Jun 30 at 7:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.