clsn / mysqlfuse

Present a MySQL database as a filesystem under FUSE
16 stars 4 forks source link

Writing data into files does not update SQL database records #3

Open cweiske opened 9 years ago

cweiske commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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.