Hi,

I am using the flask-sqlalchemy extension with MySQL (default 
configuration), and I have a structure similar to the following example:

class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)

    def __init__(self):
        return


class A(User):
    id = db.Column(db.Integer, db.ForeignKey('user.id'), primary_key=True)

    def __init__(self):
        super(A, self).__init__()


class B(User):
    id = db.Column(db.Integer, db.ForeignKey('user.id'), primary_key=True)

    def __init__(self):

        super(B, self).__init__()



Consider the following flow-

   - a = A()
   - db.session.add(a)
   - db.session.commit()

Now I have an entry in the 'user' table with some id, and an entry in the 
'a' table with the same id. So far so good.

But now what I'm trying to accomplish, is the creation of an object (and a 
table entry) of class B *with the same id* as my class A object instance.

Whatever I tried so far with SQLAlchemy, it always ended up with a failure 
due to an insert into the 'user' table resulting in a duplicate error.

One 1 way to do so (and the only one I found so far), is via MySQL query 
(INSERT INTO b (id) VALUES (<id>)), but I would really like to figure out 
if I there's a way to do the same using SQLAlchemy functions/configuration.

Thanks,

Amit

-- 
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.

Reply via email to