mysqlfuse icon indicating copy to clipboard operation
mysqlfuse copied to clipboard

Writing data into files does not update SQL database records

Open cweiske opened this issue 10 years ago • 3 comments

Changing the contents of a file (column) does not change the actual record in the database:

$ mysql -utest -ptest test -e 'SELECT * FROM data'
+-----+--------+
| uid | title  |
+-----+--------+
|   1 | title1 |
+-----+--------+
$ ls mountpoint/data/ test/ 
$ cat mountpoint/data/uid/1/title; echo
title1
$ echo title2 > mountpoint/data/uid/1/title 
$ cat mountpoint/data/uid/1/title
title2
$ mysql -utest -ptest test -e 'SELECT * FROM data'
+-----+--------+
| uid | title  |
+-----+--------+
|   1 | title1 |
+-----+--------+

cweiske avatar Jan 13 '15 20:01 cweiske

I guess this has to to with the fact that mysqlfuse seems to use transactions. The network protocol dump shows that we're in a transaction, and autocommit is not enabled:

2015-01-13 mysqlfuse update

cweiske avatar Jan 13 '15 20:01 cweiske

The first SQL query after the login is set autocommit=0, but that is not in the mysqlfuse codebase: 2015-01-13 mysqlfuse autocommit

cweiske avatar Jan 13 '15 20:01 cweiske

This was a change in the MySQLdb package:

Starting with 1.2.0, MySQLdb disables autocommit by default, as required by the DB-API standard (PEP-249). If you are using InnoDB tables or some other type of transactional table type, you'll need to do connection.commit() before closing the connection, or else none of your changes will be written to the database.

cweiske avatar Jan 13 '15 20:01 cweiske