Appearently I didn't really understand the whole AutoCommit problem
until now. As far as I can see all databases supporting transactions
have something like AutoCommit active by default, which means that they
automatically commit every SQL statement that is run outside a
transaction (that's the way someone who doesn't use transactions expects
it to be). But when AutoCommit is off (default in Ruby/DBI), the SQLite
DBD starts a transaction automatically after creating the connection.
This behaviour is quite surprising, and I remember reading a complaint
about this on ruby-talk some time ago. That's especially a problem with
SQLite, because it locks the whole database when a transaction is
active, so with AutoCommit=off only one connection at a time can exist.
Python uses AutoCommit=off by default, too, but I don't think this is
good. It wouldn't be too hard to tell people to use
transaction.do
# execute some SQL statements
end
instead of
# execute some SQL statements
dbh.commit
(the former is actually more ruby-like).
What do you think?
|