Answer the question
In order to leave comments, you need to log in
Why does sqlacodegen generate tables in the form of classes for some Mysql tables, and for other tables in the form of Tables?
There is sqlacodegen module
https://pypi.python.org/pypi/sqlacodegen/1.1.4
Which generates code for further use in SQLAlchemy.
Some tables, it generates like this:
class User(Base):
__tablename__ = 'user'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(128))
t_users_forum = Table(
'users_forum', metadata,
Column('id', Integer, nullable=False),
Column('login', String(25), nullable=False),
)
Answer the question
In order to leave comments, you need to log in
Lines 532-537
# Only form model classes for tables that have a primary key and are not association tables
if not table.primary_key or table.name in association_tables:
model = ModelTable(table)
else:
model = ModelClass(table, links[table.name], inflect_engine, not nojoined)
classes[model.name] = model
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question