http://qs1969.pair.com?node_id=219442


in reply to forking and dbi

The short (indeed the long) answer is that you can't share a single database connection between processes. You'll need to open a new $dbh in each fork.


Update: 14/12/02

I lied. Oops.

It turns out that some DBDs do support access to the same $dbh in different processes - so in specific cases you can do this. You just have to be careful to make sure that you do not close the handle in one process if you want to continue using it in another.

However, if you want to write code that is portable across databases then you should consider avoiding this, because not all DBDs support it.