in reply to Changing Modules in Bad Code

Option 1, hands down.

You'll find it's not as bad as you fear to translate, and you'll gain in portability of the code - only SQL dialect changes needed to port to another db if you haven't used any DBI methods that are not widely supported.

It would be a remarkable feat to roll your own tested Pg interface more cheaply than rewriting the application from scratch. I don't believe in it.

After Compline,
Zaxo