[MDEV-6757] autocommit does not work in MySQLdb Python connector with MariaDB Created: 2014-09-18 Updated: 2014-09-27 Resolved: 2014-09-26 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Platform Power |
| Affects Version/s: | 5.5.37 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Minor |
| Reporter: | Alan Evangelista | Assignee: | Unassigned |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Hardware architecture: x86 |
||
| Description |
|
If i run the following command in Python command line:
and then check the MariaDB database, the inserted tuple does not show up in a SELECT query output. If I commit as shown below, the new tuple shows up in SELECT query output. conn.commit() This works correctly in MySQL server 5.1.66, same MySQLdb module version. |
| Comments |
| Comment by Elena Stepanova [ 2014-09-26 ] | |||||
|
It works identically with MySQL 5.1.66 and MariaDB (or MySQL 5.5), see http://mysql-python.sourceforge.net/FAQ.html:
For your conn.autocommit = True call, I'm not quite sure what it is supposed to do, MySQLdb does not seem to support autocommit attribute for connections: http://mysql-python.sourceforge.net/MySQLdb.html#mysqldb The most likely reason why you see the difference is that you use a default storage engine, which is MyISAM in 5.1 and InnoDB in 5.5. So, in 5.1 the presence or absence of autocommit won't make any difference, while in 5.5 it will. To double-check, create the table with an explicit engine on both servers and run the test. | |||||
| Comment by Alan Evangelista [ 2014-09-27 ] | |||||
|
You are right about default storage engine, the involved table is using MyISAM in MySQL server and it is using InnoDB in MariaDB server. Therefore, this autocommit statement I am using never worked. I decided to investigate this further. MySQLdb connection class inherits from _mysql.connection class, which is provided by _mysql.so. In the MySQLdb documentation you mentioned, I read "There are many more methods defined on the connection object which are MySQL-specific. For more information on them, consult the internal documentation using pydoc.". Running pydoc _mysql, I see: (...)
I changed my code from
to
and now autocommit works in MariaDB. I got confused by some incorrect information posted in Internet. Thanks for the help! |