title: python try, except an error from modules that where not imported explicitly
body: <p>When a module class is not in my script but used by one of the modules (I did imported explicitly) how do I catch his error? </p>
  
  <p>For example:</p>
  
  <pre><code>from sqlite3 import dbapi2 as sqlite
  
  class sqldb:
  
  def __init__(self):
    self.sqlite.connect('records.db')
    self.c = self.conn.cursor()    
  
  def query(self,query,values)
   try:
    self.c.execute(query, values)
    self.conn.commit()
   except sqlite3.OperationalError:
    print "SQLite DB locked"
  </code></pre>
  
  <p>Will result in (when the database is locked):</p>
  
  <pre><code>NameError: global name 'sqlite3' is not defined
  </code></pre>
  
  <p>But when I don't catch the error it gives me exactly that exception: 'sqlite3.OperationalError'</p>
  
  <p>So what should I put as Except ? Or should I just import the whole sqlite3 module? If yes, doesn't this increase the resources footprint of my program?</p>