title: SQLAlchemy inheritance from non-orm class
body: <p>I'm trying to develop a ORM-version of my non-ORM class to be able to store the object in a database (and retrieve it back, if possible).</p>
  
  <pre><code>from ruamel.yaml import YAMLObject
  
  class User(YAMLObject):
      yaml_tag = u'user'
  
      def __init__(self, name, age):
          self.name = name
          self.age = age
  
      # Other useful methods
  </code></pre>
  
  <p>What I would like to achieve now is a similar object, that acts like <code>User</code> in the Python world, but that can be used also as an ORM object, hence being able to store it in a database. What I tried, ingenuously, is:</p>
  
  <pre><code>Base = declarative_base()
  
  class SQLUser(Base, User):
  
      id = Column(Integer, primary_key=True)
      name = Column(String)
      age = Column(Integer)
  
      def __init__(self, name, age):
          self.name = name
          self.age = age
  </code></pre>
  
  <p>Running an example with this class hierarchy produces, on Python 2, the following error: </p>
  
  <blockquote>
    <p><strong>TypeError</strong>: Error when calling the metaclass bases
        metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases</p>
  </blockquote>
  
  <p>I believe this is related to <code>YAMLObject</code> metaclass... But I need it since I would like also to be able to save those objects as YAML. For what I read about this error I should, maybe, use a third metaclass that inherits both from <code>YAMLObject</code> metaclass and <code>Base</code>, then using it to create the class I want...</p>
  
  <pre><code>class MetaMixinUser(type(User), type(Base)):
      pass
  
  class SQLUser(six.with_metaclass(MetaMixinUser)):
      #[...]
  </code></pre>
  
  <p>Unfortunately this gives another error: </p>
  
  <blockquote>
    <p><strong>AttributeError</strong>: type object 'SQLUser' has no attribute '_decl_class_registry'</p>
  </blockquote>
  
  <p>Could you please point me where my reasoning is flawing?</p>