title: Generic way to get primary key from declaratively defined instance in SQLAlchemy
body: <p>Does SQLAlchemy offer a <em>generic</em> way to get the primary key from a declaratively defined instance, so that if:</p>
  
  <pre><code>Base = declarative_base()
  
  class MyClass(Base):
      __tablename__ = 'mytable'
      key = Column(Integer, primary_key=True)
  </code></pre>
  
  <p>I can do:</p>
  
  <pre><code>&gt;&gt;&gt; a = MyClass(key=1)
  &gt;&gt;&gt; a.generic_get_primary_key()  # &lt;-- does it exist ??
  1
  </code></pre>