* shabda <[EMAIL PROTECTED]> [2008-04-04 14:10 -0700]: > > I am using mysql ith InooDB. > I have some cutsom sql doing inserts. These inserts are not visible > after the function returns, if I so something like > sql = 'INSERT INTO tbl1 ...' > from django.db import connection > cursor = connection.cursor() > cursor.execute(sql) > return cursor.fetchall() > > However if I do something like > > cursor.execute("set autocommit = 1") > and then do the above code the inserts are visible in a dirrent mysql > session. > > So how does django transaction management work with custom sql, and > would my calling cursor.execute("set autocommit = 1") interfare with > it?
In django, autocommit is disabled by default (actually this is done by the python db api, and it is part of its specs). You shouldn't set autocommit by yourself, as this conflicts with the idea of transactions. If you are doing custom sql, you have to call commit explicitly. Read http://www.djangoproject.com/documentation/transactions/ I don't know what is dirrent sql, but assuming it is some kind of a mysql shell, it is possible that the results of a transaction are not imediately seen. There was a thread here dealing with this about 3 weeks ago, you may look for "Django application does not see db changes made by external sources". As for the mysql behaviour, you can read the full explanation at http://dev.mysql.com/books/mysqlpress/mysql-tutorial/ch10.html Hope this helps, Amit > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---