skoovill
skoovill

Reputation: 1199

Is there a workaround in sqlalchemy for loading a table from DB without any primary keys?

I have a situation where i load all tables from legacy database. but it gives an error since it does not have any primary keys.

Can anyone give me a solution for this error ?

Upvotes: 3

Views: 203

Answers (1)

GHZ
GHZ

Reputation: 3535

You can add the primary key information to the autoloaded table.

e.g.

class Subscrib(Base):

    __tablename__ = 'mytable'
    __table_args__ = {'autoload' : True}

    thepk = Column(Integer, primary_key=True)

Upvotes: 1

Related Questions