cx_Oracle: how do I get the ORA-xxxxx error number?
<p>In a try/except block, how do I extract the Oracle error number?</p>

<pre><code>try:
   cursor.execute("select 1 / 0 from dual")
except cx_Oracle.DatabaseError, exc:
   error, = exc
   print "Code:", error.code
   print "Message:", error.message
</code></pre>

<p>This results in the following output:</p>

<pre><code>Code: 1476
Message: ORA-01476: divisor is equal to zero
</code></pre>
