Python couldn't insert row to MySQL
Question: I'm trying to accomplish following query:

    
    
    sql = "INSERT INTO adr_citydistricts (CityDistrict, CityDistrictRU) VALUES (% (ua) s,% (ru) s);"
    data = {'ua': 'ukrainian', 'ru': 'russian'}
    cursor.execute (sql, data)
    

After executing this query, there is no such record in table.

If do the same query in SQLyog, record will exists.

I've also tried:

    
    
    sql = "INSERT INTO adr_citydistricts (CityDistrict, CityDistrictRU) VALUES ('123 ', '333');"
    cursor.execute (sql)
    print sql
    

and there is no row in the table.

The console displays : `INSERT INTO adr_citydistricts (CityDistrict,
CityDistrictRU) VALUES ('123 ', '333');`

Executing this query in SQLyog, normally inserts a row in the table.

I've created another table with the same structure.

Can someone help me, please?


Answer: You need to [`cursor.commit()`](http://dev.mysql.com/doc/connector-
python/en/connector-python-api-mysqlconnection-commit.html) to reflect
changes.

> ### [9.2.3. Method
> `MySQLConnection.commit()`](http://dev.mysql.com/doc/connector-
> python/en/connector-python-api-mysqlconnection-commit.html)
>
> This method sends a COMMIT statement to the MySQL server, committing the
> current transaction. Since by default Connector/Python does not autocommit,
> it is important to call this method after every transaction that modifies
> data for tables that use transactional storage engines.

