title: Why am I getting a "relation does not exist" error for existing table with sqlalchemy Metadata?
body: <p>I have the following code which throws the following error </p>
  
  <pre><code>engine = create_engine('postgresql+psycopg2:....', convert_unicode=True)
  
  metadata = sqlalchemy.MetaData()
  table = sqlalchemy.Table('omni.all_order', metadata,
      sqlalchemy.Column('o_id', sqlalchemy.Integer),
      sqlalchemy.Column('order', sqlalchemy.String),
  
  )
  
  ins = table.insert().values(all_rows)
  engine.execute(ins)
  </code></pre>
  
  <blockquote>
    <p>sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) relation
    "omni.all_order" does not exist</p>
  </blockquote>
  
  <p>But the following two codes work fine</p>
  
  <pre><code>engine = create_engine('postgresql+psycopg2:....', convert_unicode=True)
  
      result = engine.execute("SELECT * from omni.all_order ")
      rows = result.fetchall()
      print(rows)
  </code></pre>
  
  <p>--</p>
  
  <pre><code> engine = create_engine('postgresql+psycopg2:....', convert_unicode=True)
  
      engine.execute("INSERT INTO omni.all_order (o_id) VALUES (1) ")
  </code></pre>
  
  <p>Creating another table first in the same schema (omni) throws the same error</p>
  
  <pre><code>engine = create_engine('postgresql+psycopg2:....', convert_unicode=True)
  
      result = engine.execute("CREATE TABLE omni.all_order_s(o_id INT, order VARCHAR(80))")
  
      metadata = sqlalchemy.MetaData()
      table = sqlalchemy.Table('omni.all_order_s', metadata,
          sqlalchemy.Column('o_id', sqlalchemy.Integer),
          sqlalchemy.Column('order', sqlalchemy.String),
  
      )
  
      ins = table.insert().values(all_rows)
      engine.execute(ins)
  </code></pre>
  
  <blockquote>
    <p>sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) relation
    "omni.all_order_s" does not exist</p>
  </blockquote>
  
  <p>but creating it outside of the schema works fine</p>
  
  <pre><code>engine = create_engine('postgresql+psycopg2:....', convert_unicode=True)
  
      result = engine.execute("CREATE TABLE all_order_s(o_id INT, order VARCHAR(80))")
  
          metadata = sqlalchemy.MetaData()
          table = sqlalchemy.Table('all_order_s', metadata,
              sqlalchemy.Column('o_id', sqlalchemy.Integer),
              sqlalchemy.Column('order', sqlalchemy.String),
  
          )
  
          ins = table.insert().values(all_rows)
          engine.execute(ins)
  </code></pre>
  
  <p>Any ideas why this is?</p>