Skip to content

adding arg to create model classes for tables w/o primary keys #366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

adding arg to create model classes for tables w/o primary keys #366

wants to merge 2 commits into from

Conversation

pwyllcrusader
Copy link

@pwyllcrusader pwyllcrusader commented Feb 13, 2025

In order to maintain some existing code there is a need to create Model Classes for all tables in database. So here I added a simple option to create Model Classes for every table

@agronholm
Copy link
Owner

But model classes will NOT work without primary keys, so what is this meant for?

@pwyllcrusader
Copy link
Author

But model classes will NOT work without primary keys, so what is this meant for?

well, I'm trying to replace some existing ORM classes with autogenerated ones. I didn't check every of them in use but I bet I saw such cases. What do you mean buy they didn't work?

@agronholm
Copy link
Owner

See here. In particular:

All ORM mapped classes require at least one column be declared as part of the primary key, typically by using the Column.primary_key parameter on those mapped_column() objects that should be part of the key.

The SQLAlchemy session contains a mapping of mapped class instances by their primary key values. If there is no primary key, this mapping cannot be done and the class is invalid.

@pwyllcrusader
Copy link
Author

See here. In particular:

All ORM mapped classes require at least one column be declared as part of the primary key, typically by using the Column.primary_key parameter on those mapped_column() objects that should be part of the key.

The SQLAlchemy session contains a mapping of mapped class instances by their primary key values. If there is no primary key, this mapping cannot be done and the class is invalid.

ok, sorry for doing things in a hurry and bothering you. I have to take a closer look on the task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants