Shylent's post meets the OP's request for equivalent code. However it does not adequately address the issue of what is Python's equivalent to the Perl DBI.
For those not familiar with Perl's DBI, it provides a common interface for all database systems. To add support for new storage backend, a database driver or DBD needs to be written. Drivers exist for many different database systems, and even non-database targets like CSV files and spreadsheets.
It looks like the Python DB-API is the closest thing to the Perl DBI. However it is a specification, and not an implementation. To what extent any database driver conforms to the specification up to the author.
Of course, database systems vary in what SQL commands and syntax they support. Databases vary quite a bit in what features they provide. Any system that attempts to standardize database interaction will have portability issues to address as all these differing systems provide distinct feature sets.
My experience with Perl DBI has been very positive. It is fairly easy to write portable code that works with many DBD drivers. I have successfully used 4 different database drivers (Postgres, MySQL, a CSV file driver, and SQLite) in a single application by simply changing the database connection string. For more complex apps which need to access more "incompatible" features of the database, there are a number of abstraction libraries that extend the DBI interface and further simplify portability.
I don't have enough Python experience to be able to say how PEP249 plays out in the real world. My hope is that database driver developers hew close to the spec, and portability is easy to obtain. Perhaps someone with a deeper knowledge of Python will be able to expand on this topic. There is some information on Python database access at the Python wiki.