I don't understand exactly what you are trying to do here, from a database perspective. Your table setup suggests that you are using joined-table inheritance:
http://docs.sqlalchemy.org/en/rel_1_0/orm/inheritance.html#joined-table-inheritance ie. attributes that are common to all classes in the hierarchy live in the base table, and attributes that are specific to one of the subclasses live in a subclass-specific table. So when you have a user of type A, with id 1, the common attributes will be in the user table with id 1, and the A-specific attributes will be in the A table, again with id 1. If that's really what you've got, then it doesn't make any sense to create a B object with an id of 1, since half of its identity would be the same row as your A instance. I don't think SQLAlchemy will allow that. There are other inheritance patterns that might make sense for your situation, or if you are trying to share state between and A and a B instance then you probably don't want inheritance at all, but a shared relationship instead. If you can tell us what you are trying to do, we might be able to suggest an approach. Simon On Mon, Nov 30, 2015 at 4:46 PM, amit geron <amit.ge...@gmail.com> wrote: > As I already mentioned, I tried your suggestion but with no success. The > names are unique anyway, and I don't understand the how it's related to my > question.. > > Could you please provide a working example that will demonstrate how 2 > objects inherit from the same class, and hold the same primary key that is > a primary foreign key of the derived class? > > > On Monday, November 30, 2015 at 5:59:38 PM UTC+2, Jonathan Vanasco wrote: >> >> It should still work as a reference because the pacakge you use doesn't >> override this. >> >> The extension's API makes this clear: >> http://flask-sqlalchemy.pocoo.org/2.1/api/#models >> >> >> _tablename__ >> <http://flask-sqlalchemy.pocoo.org/2.1/api/#flask.ext.sqlalchemy.Model.__tablename__> >> >> The name of the table in the database. This is required by SQLAlchemy; >> however, Flask-SQLAlchemy will set it automatically if a model has a >> primary key defined. If the __table__ or __tablename__ is set >> explicitly, that will be used instead. >> > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy+unsubscr...@googlegroups.com. > To post to this group, send email to sqlalchemy@googlegroups.com. > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.